2017 © Pedro Peláez
 

library nextcloud-api-wrapper

A simple wrapper around nextcloud user provisioning api

image

sysmoh/nextcloud-api-wrapper

A simple wrapper around nextcloud user provisioning api

  • Thursday, April 26, 2018
  • by sysmoh
  • Repository
  • 1 Watchers
  • 1 Stars
  • 429 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 46 % Grown

The README.md

Nextcloud API wrapper for PHP

This is a simple php wrapper around - user provisioning api - shares api, (*1)

which allows you to manage your nextcloud instance dynamically. It's meant to be the closest possible to the API, every parameter is available and method names should be understandable enough, dont hesitate to make use of the api documentation seeking help on what params are available for each method., (*2)

This library was partially tested with nextcloud 12 and 13. It was developed to fit my needs but I implemented all remaining methods. If you find any bug, don't hesitate to open an issue., (*3)

Warning

Nextcloud API uses basic http auth, which means username and password are not encoded and travel the internet as clearly as possible. Make sure to enforce it using SSL., (*4)

Installation

Install it with composer, (*5)

composer require sysmoh/nextcloud-api-wrapper

Basic usage

The library depends on Guzzle to make requests and Symfony's options resolver., (*6)


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

Making your own requests

If you'd like to perform your own requests, you can use the underlying nextcloud connection class to perform them., (*7)

$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'
]);

Licence

MIT, (*8)

The Versions

26/04 2018

dev-master

9999999-dev

A simple wrapper around nextcloud user provisioning api

  Sources   Download

MIT

The Requires

 

by Avatar sysmoh

api wrapper nextcloud

27/02 2018

0.1.1

0.1.1.0

A simple wrapper around nextcloud user provisioning api

  Sources   Download

MIT

The Requires

 

by Avatar sysmoh

api wrapper nextcloud

18/02 2018

0.1.0

0.1.0.0

A simple wrapper around nextcloud user provisioning api

  Sources   Download

MIT

The Requires

 

by Avatar sysmoh

api wrapper nextcloud