zimo-xiao / zuggr-cloud-sdk
v0.0.6
2019-10-21 00:48 UTC
Requires
- guzzlehttp/guzzle: ^6.3
- nikic/fast-route: ^1.3
- psr/simple-cache: ^1.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-10-01 01:03:38 UTC
README
此仓库包含开源PHP SDK,允许您从您的PHP应用程序访问Zuggr Cloud。
安装
可以使用Composer安装Zuggr Cloud PHP SDK。运行以下命令
composer require zimo-xiao/zuggr-cloud-sdk
用法
对Zuggr Cloud的简单请求
require_once __DIR__ . '/vendor/autoload.php'; // change path as needed $config = [ 'app_id' => 'foo', 'app_secret' => 'bar', 'client_config' => [ 'node' => 'zcbj' ] ]; /** * Instantiates a new ZuggrCloud super-class object. * * @param CacheInterface $cache * @param array $config * @param bool $mock * * @throws ZuggrCloudException */ $zuggr = new ZuggrCloud\ZuggrCloud($cache, $config, false); /** * Makes request to Zuggr Cloud and returns the result * * @param string $uri * @param array $data * @param array $headers * @param bool $appAuth * @param bool $returnRequestOauth * @return array */ // for safety reasons, request_oauth will not be returned by default $zuggr->get('app/oauth/info', [], [], true); // app token auto-magically appears in request header when $appAuth = true $adminOauth = $zuggr->post('admin/oauth/login', [ 'username' => 'foo', 'password' => 'bar' ]); // if you set 'token' in data or 'Authorization' in header // $appAuth is auto-magically set to false // but for good measures, write the full params $adminInfo = $zuggr->get('admin/oauth/info', [], [ 'Authorization' => 'Bearer '.$adminOauth['access_token'] ], false);