zelax90 / learning-context-client

简单的学习上下文API客户端

v0.1 2016-01-23 01:24 UTC

This package is auto-updated.

Last update: 2024-09-20 01:16:40 UTC


README

这是Learning Context API的PHP实现

令牌存储

要使用此API,你必须实现一个令牌存储,该存储实现LearningContextClient\Storage\StorageInterface接口。使用$_SESSION数组和Zend Session的存储类分别在LearningContextClient\Storage\SessionArrayStorageLearningContextClient\Storage\ZendSessionStorage中已经提供。

配置

要运行客户端,你必须创建一个LearningContextClient\Config对象。它接收你的appId和appSecret,一个OAuth授权后被调用的回调URL,处理刷新令牌,以及LearningContextClient\Storage\StorageInterface的一个实例。只需进行任何API请求或调用LearningContextClient:::getTokenManager函数即可。

使用方法

创建一个LearningContextClient\Client的实例,并向它提供配置以使用API。

$storage = new \LearningContextClient\Storage\SessionArrayStorage();
$config = new \LearningContextClient\Config($APP_ID, $APP_SECRET, $CALLBACK_URL, $storage);
$lc = new \LearningContextClient\Client($config);

获取令牌

要获取令牌,只需调用任何API接口或调用LearningContextClient::getTokenManager函数即可。