quartetcom / base-api-php-client
PHP client library for accessing BASE API.
Installs: 29 930
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 9
Forks: 0
Open Issues: 0
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
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.