Authorize users in you application with oauth 2.0 providers
PHP
Latest commit 943aa0d Jul 30, 2015 @tlikai Merge pull request #2 from kingstudio/master
modify qq can not get openid
Permalink
Failed to load latest commit information.
providers modify qq can not get openid Jul 29, 2015
OAuth2China.php Initial commit May 15, 2013
README.md Improve readme Oct 14, 2013
composer.json Modify composer package name May 15, 2013

README.md

OAuth2China

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);
    }
}