beehamchoi / yii2-google1tap
Google One Tap 扩展
1.0
2021-01-22 10:08 UTC
Requires
- yiisoft/yii2: ~2.0.0
- yiisoft/yii2-httpclient: ^2.0
This package is not auto-updated.
Last update: 2024-09-29 05:36:37 UTC
README
Google One Tap 扩展
安装
运行以下命令之一
composer require beehamchoi/yii2-google1tap ^1.0
php composer.phar require beehamchoi/yii2-google1tap "^1.0"
或者在 composer.json
文件的 require 部分添加
"beehamchoi/yii2-google1tap": "^1.0"
。
使用方法
安装扩展后,只需在代码中使用它
views/index.php
- 注意
- 必须使用 https
- 可以更改控制器或操作
- 示例:SiteController 和 goole-onetap 操作
<?= \beehamchoi\google1tap\widgets\Google1tap::widget([
'client_id' => @your client id,
'login_uri' => Yii::$app->urlManager->createAbsoluteUrl(['/site/google-onetap'], 'https')
]) ?>
controllers/SiteController.php
public function actions(){
return [
'google-onetap' => [
'class' => Google1tapLogin::class,
'successCallback' => function ($client){
//Your code here. Can do any thing with $client.
//$client is infor of google user
}
]
];
}