changyuan/yii2-authclient
Composer 安装命令:
composer require changyuan/yii2-authclient
包简介
yii2-authclient for qq weibo wechat
README 文档
README
Installation
The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist changyuan/yii2-authclient
or add
"changyuan/yii2-authclient": "~2.1.0"
to the require section of your composer.json.
Usage
'components' => [
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'weibo' => [
'class' => 'changyuan\authclient\clients\Weibo',
'clientId' => 'wb_key',
'clientSecret' => 'wb_secret',
],
'qq' => [
'class' => 'changyuan\authclient\clients\QQ',
'clientId' => 'qq_appid',
'clientSecret' => 'qq_appkey',
],
'wechat' => [
'class' => 'changyuan\authclient\clients\Wechat',
'clientId' => 'weixin_appid',
'clientSecret' => 'weixin_appkey',
],
'wechatmp' => [
'class' => 'changyuan\authclient\clients\Wechat',
'type' => 'mp',
'clientId' => 'weixin_appid',
'clientSecret' => 'weixin_appkey',
],
],
]
// other components
]
in view
//The first way in view:
<?= yii\authclient\widgets\AuthChoice::widget([
'baseAuthUrl' => ['site/auth']
]); ?>
//The second way in view:
<?php
use yii\authclient\widgets\AuthChoice;
?>
<?php $authAuthChoice = AuthChoice::begin([
'baseAuthUrl' => ['site/auth']
]); ?>
<ul>
<?php foreach ($authAuthChoice->getClients() as $client): ?>
<li><?= $authAuthChoice->clientLink($client) ?></li>
<?php endforeach; ?>
</ul>
<?php AuthChoice::end(); ?>
Q&A
Q: this error "Invalid auth state parameter." ?
A: remove sub class $this->removeState('authState');
统计信息
- 总下载量: 109
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-10