yuyangame/yii2-oauth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yuyangame/yii2-oauth

最新稳定版本:0.1.1

Composer 安装命令:

composer require yuyangame/yii2-oauth

包简介

yii2-oauth

README 文档

README

yii2-oauth Include:QQ,Weibo,Weixin,Renren,Douban

#Installation

The preferred way to install this extension is through composer.

Either run

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

or add

"yuyangame/yii2-oauth": "*"

to the require section of your composer.json file.

#Usage

Once the extension is installed, simply use it in your code by :

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,
])
?>

统计信息

  • 总下载量: 29
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2015-06-16