quartetcom / base-api-php-client
此包已被废弃,不再维护。没有建议的替代包。
用于访问 BASE API 的 PHP 客户端库。
v1.0.0
2017-05-31 02:48 UTC
Requires
- cakephp/utility: ~3.0
- league/oauth2-client: ~1.0
Requires (Dev)
- phake/phake: 2.0.*@dev
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2023-02-01 05:45:02 UTC
README
用于访问 BASE API 的 PHP 客户端库。
需求
- PHP 5.5+
入门
只需将以下依赖项添加到您的 composer.json
文件中,如下所示
{ "require": { "quartetcom/base-api-php-client": "1.0.*@dev", "cakephp/utility": "3.0.*@beta" } }
或者
{ "require": { "quartetcom/base-api-php-client": "1.0.*@dev" }, "minimum-stability": "beta" }
用法
$clientId = '2aacd57f14ffe6edafd402934593a0ce'; $clientSecret = '2e3389dc5fe7c9607115541e409dd2c3'; $callbackUrl = 'http://hogehoge.com/callback'; $scopes = [ 'read_users', 'read_items', ]; // Initialize BASE API client object. $client = new Quartet\BaseApi\Client($clientId, $clientSecret, $callbackUrl, $scopes); // OAuth. if (isset($_GET['code'])) { $client->authenticate($_GET['code']); // authenticate with query string of 'code'. } else { $client->authorize(); // redirect to BASE authorization page and get code. } // Call APIs via API Classes. $usersApi = new Quartet\BaseApi\Api\Users($client); $user = $usersApi->me(); // You got response from API as an object. var_dump($user); // object(Quartet\BaseApi\Entity\User)[30] // public 'shop_id' => string 'sample_shop' (length=11) // public 'shop_name' => string 'sample shop name' (length=16) // public 'shop_introduction' => string '' (length=0) // public 'shop_url' => string 'http://sample_shop.thebase.in' (length=29) // public 'twitter_id' => string '' (length=0) // public 'facebook_id' => string '' (length=0) // public 'ameba_id' => string '' (length=0) // public 'instagram_id' => string '' (length=0) // public 'background' => null // public 'logo' => null // public 'mail_address' => null
您可以在以下链接中查看示例代码 这里。