jpcaparas / box-sdk
v2 Box sdk for php
v0.2.4
2017-09-07 01:26 UTC
Requires
- firebase/php-jwt: ^4.0
- guzzlehttp/guzzle: ^6.2
- webmozart/assert: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7
- symfony/var-dumper: ^3.2
- symfony/yaml: ^3.2
This package is not auto-updated.
Last update: 2024-09-25 02:19:08 UTC
README
到目前为止,此SDK只支持机器间认证机制和以下功能
文件夹
- 获取文件夹信息
- 获取文件夹项目
- 创建文件夹
- 删除文件夹
- 获取回收站项目
- 销毁回收站文件夹
- 恢复回收站文件夹
文件
- 上传文件
- 上传前检查 - 此API用于检查提供的元数据是否有效。
- 获取嵌入URL
- 删除文件(软删除 - 移动到回收站)
- 销毁回收站文件
- 恢复回收站文件
用法
use Linkstreet\Box; use Linkstreet\Box\Enums\SubscriptionType; $box_sdk = new Box(['client_id' => "", "client_secret" => ""]); $app_auth_info = [ "key_id" => "key id from box app", "private_key" => "path to private key", "pass_phrase" => "passphrase", // Can be empty "subscription_type" => SubscriptionType::ENTERPRISE or SubscriptionType::USER, "id" => "enterprise id or user id" ]; // Authenticates with box server and returns app_auth instance. // Throws `GuzzleHttp\Exception\ClientException` on failure $app_auth_instance = $box_sdk->getAppAuthClient($app_auth_info);
文件夹服务
-
获取服务
$folder_service = $app_auth_instance->getFolderService();
-
$folder_service
中可用的方法1. getFolderInfo($folder_id); // Defaults to root folder (id = 0) 2. getFolderItems($folder_id = 0, $fields = [], $limit = 100, $offset = 0); // Defaults to root folder (id = 0) 3. create($folder_name, $parent_folder_id = 0) 4. delete($folder_id, $recursive = false, $e_tag = null) 5. getTrashedItems() 6. destroyTrashedFolder($folder_id) 7. restore($trashed_folder_id, $new_name = null, $parent_folder_id = null)
文件服务
-
获取服务
$file_service = $app_auth_instance->getFileService();
-
$file_service
中可用的方法1. uploadPreFlight($file_path = "", $folder_id = 0, $filename = null); // If filename is null, file name will be derived from actual file name. 2. upload($file_path = "", $folder_id = 0, $filename = null); // If filename is null, file name will be derived from actual file name. 3. getEmbedUrl($file_id) 4. delete($file_id) 5. destroyTrashedFile($file_id) 6. restore($trashed_file_id, $new_name = null, $parent_folder_id = null)
注意
- 所有API返回
\GuzzleHttp\Psr7\Response
(使用$response->getBody()->getContents()
获取内容。请参阅Guzzle HTTP Messages)除外,getEmbedUrl($file_id)
返回字符串。 - 有关Guzzle相关异常及其文档,请参阅Guzzle Docs