承接 mr4online/nextcloud-api-wrapper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mr4online/nextcloud-api-wrapper

最新稳定版本:1.0.2

Composer 安装命令:

composer require mr4online/nextcloud-api-wrapper

包简介

A simple wrapper around nextcloud user provisioning api

README 文档

README

⚠️ IMPORTANT: this is a fork of: https://github.com/ovesco/nextcloud-api-wrapper with the goal to keep dependencies and code updated. Some code may change ;-) Testing with PHP8.4 & Nextcloud 31+ WIP

This is a simple php wrapper around

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.

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.

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.

Installation

Install it with composer

composer require sysmoh/nextcloud-api-wrapper

Basic usage

The library depends on Guzzle to make requests and Symfony's options resolver.

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.

$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

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 21
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-28