Skip to content

hub/HubID-api-client

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 

Hub Culture API hubculture logo

Wiki https://github.com/hub/APIHubID/wiki

Swagger api.hubculture.com

Usage

Include the library with composer.

composer require hub/hubid-api-client

Authentication

Refer to the https://hubculture.com/developer/home for obtaining the private and public keys.

include '/vendor/autoload.php';

use Hub\HubAPI\HubClient;

$redirectUrl = 'http://localhost/callback.php';
$config = array(
    // @see https://hubculture.com/developer/home
    'private_key' => '<your private key>',
    'public_key' => '<your public key>',
    'client_id' => 12345,
);

$hubClient = new HubClient($config);

$redirectLoginHelper = $hubClient->getRedirectLoginHelper();
$redirectLoginHelper->getAccessToken($redirectUrl);

User Service

Retrieving a user by id

include '/vendor/autoload.php';

use Hub\HubAPI\Service\UserService;

$config = array(
    'private_key' => '<your private key>',
    'public_key' => '<your public key>',
    'token' => '<access_token you got from the auth endpoint>',
);

$service = new UserService($config);
$user = $service->getUserById(18495);
var_dump($user);

Examples

Please run the following command to run a PHP server serving examples.

HUBID_PRIVATE_KEY=[your-private-key] HUBID_PUBLIC_KEY=[your-public-key] make demo

Browse to http://localhost:8085/friend-service.php.

You may look at examples under examples directory.