Files
shopxo/application/plugins/shopoauth/LoginEvent.php
2019-03-15 17:46:35 +08:00

33 lines
904 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\plugins\shopoauth;
use app\plugins\shopoauth\ThinkOauth;
/**
* 登入事件
* @author Guoguo
* @blog http://gadmin.cojz8.com
* @version 1.0.0
* @datetime 2019年3月14日
*/
class LoginEvent
{
//登录成功获取腾讯QQ用户信息
public function qq($token)
{
$qq = ThinkOauth::getInstance('qq', $token);
$data = $qq->call('user/get_user_info');
if ($data['ret'] == 0) {
$userInfo['type'] = 'QQ';
$userInfo['name'] = $data['nickname'];
$userInfo['nick'] = $data['nickname'];
$userInfo['head'] = $data['figureurl_2'];
$userInfo['openid'] = $qq->openid();
$userInfo['token'] = $token;
return $userInfo;
} else {
throw new \think\Exception("获取腾讯QQ用户信息失败{$data['msg']}");
}
}
}