hub/hubid-api-client

该包最新版本(1.8.4)没有可用的许可证信息。

Hub Culture API sdk

1.8.4 2022-06-24 08:52 UTC

This package is auto-updated.

Last update: 2024-09-24 14:06:13 UTC


README

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

Swagger api.hubculture.com

使用方法

使用composer包含库。

composer require hub/hubid-api-client

身份验证

请参考https://hubculture.com/developer/home 获取公钥和私钥。

include '/vendor/autoload.php';

use Hub\HubAPI\HubClient;

$redirectUrl = 'https:///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);

用户服务

通过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);

示例

请运行以下命令来启动一个提供示例的PHP服务器。

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

浏览到 https://:8085/friend-service.php

您可以在 examples 目录下查看示例。