stephenyeargin / yammer-oauth2-php
Yammer的OAuth2包装器
v1.0.0
2015-11-09 04:02 UTC
Requires (Dev)
README
PHP包装器,用于Yammer的API。
安装
使用Composer安装
$ composer require stephenyeargin/yammer-oauth2-php
使用方法
传递给构造函数的示例配置数组
$config['consumer_key'] = '1ABCdefhiJKLmnop';
$config['consumer_secret'] = 'ABCdefhi_JKLmnop';
$config['callbackUrl'] = 'http://' . $_SERVER['SERVER_NAME'] . '/yammer/callback/';
$yammer = new YammerPHP\YammerPHP($config);
启动回调过程
// Redirect the user to the OAuth page for your application header('Location: ' . $yammer->getAuthorizationUrl());
将回调代码升级为授权令牌
$code = $_GET['code']; $token = $yammer->getAccessToken($code);
使用令牌(无论是从新进程还是从数据库中保存的)
$yammer->setOAuthToken($token);
使用$yammer实例进行调用
if (!$yammer->testAuth()) { // Handle this. } // Retrieve feed for authenticated user try { $feed = $yammer->get('messages/my_feed.json'); print_r($feed); } catch (YammerPHPException $e) { print 'Error: '; print $e->getMessage(); }