egnyte-php/egnyte

使用Egnyte公共API管理Egnyte上传

维护者

详细信息

github.com/egnyte-php/egnyte

源代码

安装: 413

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 0

分支: 4

类型:package

1.0-alpha3 2022-04-22 01:04 UTC

This package is auto-updated.

Last update: 2024-09-14 12:29:14 UTC


README

Egnyte PHP客户端

更新

  • 移动到EgnytePhp命名空间
  • 添加了代码检查
  • php 8.0+
  • @todo 分块上传
  • @todo 测试用例

初步

  1. 在 (develpers.egnyte.com)[https://develpers.egnyte.com] 注册开发者密钥

    1. 密钥应该是 "内部应用"

    2. 提供您的Egnyte账户的API子域

  2. 确保您有Web UI的凭证。此登录称为“资源所有者”凭证。

  3. 等待您的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' );