PHP code example of sysmoh / nextcloud-api-wrapper
1. Go to this page and download the library: Download sysmoh/nextcloud-api-wrapper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sysmoh / nextcloud-api-wrapper example snippets
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
$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'
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.