2017 © Pedro Peláez
 

yii2-extension yii2-oauth

yii2-oauth

image

yuyangame/yii2-oauth

yii2-oauth

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

yii2-oauth

yii2-oauth Include:QQ,Weibo,Weixin,Renren,Douban, (*1)

#Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist yuyangame/yii2-oauth "*"

or add, (*4)

"yuyangame/yii2-oauth": "*"

to the require section of your composer.json file., (*5)

#Usage

Once the extension is installed, simply use it in your code by :, (*6)

1.Add components configure

'components' => [
    'authClientCollection' => [
        'class' => 'yii\authclient\Collection',
        'clients' => [
            'qq' => [
                'class' => 'yuyangame\oauth\QqAuth',
                'clientId' => 'YOUR_OPEN_APPID',
                'clientSecret' => 'YOUR_OPEN_APPSCRET',
            ],
            'weibo' => [
                'class' => 'yuyangame\oauth\WeiboAuth',
                'clientId' => 'YOUR_OPEN_APPID',
                'clientSecret' => 'YOUR_OPEN_APPSCRET',
            ],
            'weixin' => [
                'class' => 'yuyangame\oauth\WeixinAuth',
                'clientId' => 'YOUR_OPEN_APPID',
                'clientSecret' => 'YOUR_OPEN_APPSCRET',
            ],
        ]
    ]
    ...
]

2.Add controller

class SiteController extends Controller
{
    public function actions()
    {
        return [
            'auth' => [
                'class' => 'yii\authclient\AuthAction',
                'successCallback' => [$this, 'successCallback'],
            ],
        ];
    }

    /**
     * Success Callback
     * @param QqAuth|WeiboAuth $client
     * @see http://wiki.connect.qq.com/get_user_info
     * @see http://stuff.cebe.cc/yii2docs/yii-authclient-authaction.html
     */
    public function successCallback($client) {
        $id = $client->getId(); // qq | weibo | weixin
        $attributes = $client->getUserAttributes(); // basic info
        $userInfo = $client->getUserInfo(); // user extend info
        // login or signup
    }
}

3.Add view

<?=
yii\authclient\widgets\AuthChoice::widget([
    'baseAuthUrl' => ['site/auth'],
    //'popupMode' => false,
])
?>

The Versions

16/06 2015

dev-master

9999999-dev

yii2-oauth

  Sources   Download

GPL-3.0+

The Requires

 

extension oauth yii2

16/06 2015

0.1.1

0.1.1.0

yii2-oauth

  Sources   Download

GPL-3.0+

The Requires

 

extension oauth yii2

16/06 2015

0.1.0

0.1.0.0

yii2-oauth

  Sources   Download

GPL-3.0+

The Requires

 

extension oauth yii2