egnyte-php / egnyte
使用Egnyte公共API管理Egnyte上传
1.0-alpha3
2022-04-22 01:04 UTC
Requires
- php: >=8.0
- ext-curl: *
- php-curl-class/php-curl-class: ^9.6
Requires (Dev)
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.6
- vlucas/phpdotenv: ^2.4@dev
This package is auto-updated.
Last update: 2024-09-14 12:29:14 UTC
README
Egnyte PHP客户端
更新
- 移动到EgnytePhp命名空间
- 添加了代码检查
- php 8.0+
- @todo 分块上传
- @todo 测试用例
初步
-
在 (develpers.egnyte.com)[https://develpers.egnyte.com] 注册开发者密钥
-
密钥应该是 "内部应用"
-
提供您的Egnyte账户的API子域
-
-
确保您有Web UI的凭证。此登录称为“资源所有者”凭证。
-
等待您的API密钥被批准(通常少于24小时)。
重要:此时需要以下值
$key = API Key
$secret = API Secret
$username = Resource Owner Username
$password = Resource Owner Password
使用
$api_subdomain = 'something-something'; // ==> becomes something-something.egnyte.com $oauth = new \Oauth($key, $secret, OAUTH_SIG_METHOD_HMACSHA256, OAUTH_AUTH_TYPE_FORM); $tokenArray = $oauth->getRequestToken($api_subdomain ".egnyte.com/puboauth/token", [ "username" => $username, "password" => $password, "grant_type" => "password" ]); $client = new \EgnytePhp\Egnyte\Client( $api_subdomain, $tokenArray['access_token']); $fileClient = new \EgnytePhp\Egnyte\Model\File( $client ); // OR $fileClient = new \EgnytePhp\Egnyte\Model\File( null, 'domain', 'oauth token' ); $response = $fileClient->upload('/Shared/Documents/test.txt', 'test file upload' );