tlikai / oauth2china
Authorize users in you application with oauth 2.0 providers
Installs: 124
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 3
Forks: 1
Open Issues: 1
Type:yii-extension
Requires
- php: >=5.0
This package is not auto-updated.
Last update: 2024-12-21 15:34:26 UTC
README
OAuth2China 是一个支持国内多家社交平台OAuth授权的扩展,需要PHP CURL扩展支持
OAuth2China支持下列平台
- 新浪微博
- QQ空间
- 豆瓣
- 人人
使用方法
public function actionAuth($provider)
{
// 导入OAuth2China
Yii::import('ext.yii-oauth2china.OAuth2China');
// 配置各平台参数
$providers = array(
'weibo' => array(
'id' => 'App key',
'secret' => 'App secret',
),
'qq' => array(
'id' => 'APP ID',
'secret' => 'APP KEY',
),
'douban' => array(
'id' => 'API Key',
'secret' => 'Secret',
),
'renren' => array(
'id' => 'API key',
'secret' => 'Secret key',
),
);
$OAuth2China = new OAuth2China($providers);
$provider = $OAuth2China->getProvider('qq'); // getProvider方法的参数对应$providers配置中的key
if(!isset($_GET['code']))
{
// 跳转到授权页面
$provider->redirect();
}
else
{
// 获取access token
$token = $provider->getAccessToken($_GET['code']);
var_dump($token);
}
}