Skip to content
MercierCorentin edited this page Apr 13, 2019 · 3 revisions

Nextcloud User provisionning API client

Forked from MasterZero/laravel-nextcloud-user-management.

The rest is based on Nextcloud provisionning API doc and Nextcloud source code. When the documentation had some lacks, I submited PR:

Organization

This API client is divided in three parts:

Setup

  1. Use following command in your terminal to install this library. (Currently the library is in development mode):
composer require MercierCorentin/nextcloud dev-master
  1. Create config/nextcloud.php with content:
return [
    'login'=> env('NEXTCLOUD_LOGIN', 'admin'),
    'password'=> env('NEXTCLOUD_PASSWORD', '12345678'),
    'baseUrl'=> env('NEXTCLOUD_BASEURL', 'http://localhost'),
];
  1. Add these params to .env (recommended):
NEXTCLOUD_LOGIN=admin
NEXTCLOUD_PASSWORD=12345678
NEXTCLOUD_BASEURL=http://localhost
  1. Update Aliases and providers for subpart needed (User, App, Group).

Exceptions

use MercierCorentin\Nextcloud\Exceptions\XMLParseException;
use MercierCorentin\Nextcloud\Exceptions\CurlException;

// ... 

try {
    // reqeust to API
    UserApi::editUser('rabbit','quota', '200 MB');
} catch (XMLParseException $e) {
    // bad nextcloud answer
} catch (CurlException $e) {
    // bad connection
} catch (\Exception $e) {
    // bad something else
}

multi-server usage

// Exaple for UserApi
use MercierCorentin\Nextcloud\User\UserApi;

// ... 
// 
$api = new UserApi([
    'baseUrl' => 'http://develop.localhost:3500',
    'login' => 'admin',
    'password' => '12345678',
    'sslVerify' => false,


    // use default value
    // 'apiPath' => 'custom/path/to/api.php', 
    // 'userPath' => '',
    // 'enablePath' => '',
    // 'disablePath' => '',
]);


$api->createUser( 'dummy', 'azerty');

Clone this wiki locally