sysmoh / nextcloud-api-wrapper
封装nextcloud用户配置API的简单工具
0.1.1
2018-02-27 10:18 UTC
Requires
- guzzlehttp/guzzle: ^6.3
- symfony/options-resolver: ^3.4
This package is not auto-updated.
Last update: 2024-09-29 04:43:14 UTC
README
这是一个简单的php封装,围绕用户配置API、共享API,允许您动态管理您的nextcloud实例。它旨在尽可能接近API,每个参数都是可用的,方法名应该足够易懂,请随时利用API文档寻求帮助,了解每个方法可用的参数。
它允许您动态管理您的nextcloud实例。它的目标是尽可能接近API,每个参数都是可用的,方法名应该足够易懂,请随时利用API文档寻求帮助,了解每个方法可用的参数。
这个库在nextcloud 12和13上进行了部分测试。它是为了满足我的需求而开发的,但我实现了所有剩余的方法。如果您发现任何错误,请随时提交问题。
警告
Nextcloud API使用基本HTTP身份验证,这意味着用户名和密码不会被编码,并且以尽可能清晰的方式在互联网上传输。请确保使用SSL强制执行。
安装
使用composer安装
composer require sysmoh/nextcloud-api-wrapper
基本用法
该库依赖于Guzzle进行请求和Symfony的选项解析器。
use NextcloudApiWrapper\Wrapper; //The base path to Nextcloud api entry point, dont forget the last '/' $basePath = 'http://my.domain.com/nextcloud/ocs/'; $username = 'admin'; $password = 'potatoes'; $wrapper = Wrapper::build($basePath, $username, $password); // https://docs.nextcloud.com/server/12/admin_manual/configuration_user/user_provisioning_api.html $userClient = $wrapper->getUsersClient(); $groupsClient = $wrapper->getGroupsClient(); $appsClient = $wrapper->getAppsClient(); // https://docs.nextcloud.com/server/12/developer_manual/core/ocs-share-api.html $sharesClient = $wrapper->getSharesClient(); $federatedCloudSharesClient = $wrapper->getFederatedCloudSharesClient(); //Instance of \NextcloudApiWrapper\NextcloudResponse $response = $userClient->getUsers(); $code = $response->getStatusCode(); //status code $users = $response->getData(); //data as array $message = $response->getStatus(); //status message $guzzle = $response->getRawResponse(); //Guzzle response
自定义请求
如果您想执行自己的请求,可以使用底层nextcloud连接类来执行。
$connection = new \NextcloudApiWrapper\Connection($basePath, $username, $password); //To perform simple requests $response = $connection->request('GET', 'cloud/users'); //To perform requests which needs the 'application/x-www-form-urlencoded' header //and are not performed in POST $response = $connection->pushDataRequest('PUT', 'cloud/' . $username . '/disable'); //To perform requests which holds some values to submit $response = $connection->submitRequest('POST', 'cloud/users', [ 'userid' => 'potatoes', 'password' => 'tortilla' ]);
许可
MIT