quartetcom/base-api-php-client
最新稳定版本:v1.0.0
Composer 安装命令:
composer require quartetcom/base-api-php-client
包简介
PHP client library for accessing BASE API.
README 文档
README
PHP client library for accessing BASE API.
Requirements
- PHP 5.5+
Getting started
Just add this dependency into your composer.json as below:
{
"require": {
"quartetcom/base-api-php-client": "1.0.*@dev",
"cakephp/utility": "3.0.*@beta"
}
}
or:
{
"require": {
"quartetcom/base-api-php-client": "1.0.*@dev"
},
"minimum-stability": "beta"
}
Usage
$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
You can see demo code here.
See also
统计信息
- 总下载量: 29.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-08