quartetcom/base-api-php-client

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP client library for accessing BASE API.

v1.0.0 2017-05-31 02:48 UTC

This package is not auto-updated.

Last update: 2023-02-01 05:45:02 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads

日本語はこちら

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