Qqconnect
基于thinkphp5和Oauth2.0的QQ互联登陆
Install / Use
/learn @loveteemo/QqconnectREADME
ThinkPHP 5 & Oauth2.0 QQ登录
类库是基于Oauth2.0结合ThinkPHP 5 修改部分内容,仅适配 ThinkPhP 5
个人博客主页: http://www.loveteemo.com
安装方法
composer安装:
composer require loveteemo/qqconnect
添加公共配置:
// QQ 互联配置 在config.php中添加
'qqconnect' => [
'appid' => '',
'appkey' => '',
'callback' => '',
'scope' => 'get_user_info',
'errorReport' => true
]
示例
页面编写:
<a href="{:url('Base/qqlogin')}">QQ登录</a>
控制器编写:
登录
namespace app\index\controller;
use loveteemo\qqconnect\QC;
class Base
{
public function qqlogin()
{
$qc = new QC();
return redirect($qc->qq_login());
}
}
回调
namespace app\index\controller;
use loveteemo\qqconnect\QC;
class Base
{
public function callback()
{
$Qc = new QC();
$access_token = $Qc->qq_callback();
$openid = $Qc->get_openid();
$Qc = new QC($access_token,$openid);
$qq_user_info = $Qc->get_user_info();
//打印数据
//dump($qq_user_info);die;
// ...
// 用户逻辑
return redirect(url('Index/index'));
}
}
获取到的QQ数据
array(18) {
["ret"] => int(0)
["msg"] => string(0) ""
["is_lost"] => int(0)
["nickname"] => string(21) "那年,烟雨重楼"
["gender"] => string(3) "男"
["province"] => string(6) "广东"
["city"] => string(6) "深圳"
["year"] => string(4) "1993"
["figureurl"] => string(73) "http://qzapp.qlogo.cn/qzapp/101232670/7C8F797F30B08554A6E39A537F9A324B/30"
["figureurl_1"] => string(73) "http://qzapp.qlogo.cn/qzapp/101232670/7C8F797F30B08554A6E39A537F9A324B/50"
["figureurl_2"] => string(74) "http://qzapp.qlogo.cn/qzapp/101232670/7C8F797F30B08554A6E39A537F9A324B/100"
["figureurl_qq_1"] => string(69) "http://q.qlogo.cn/qqapp/101232670/7C8F797F30B08554A6E39A537F9A324B/40"
["figureurl_qq_2"] => string(70) "http://q.qlogo.cn/qqapp/101232670/7C8F797F30B08554A6E39A537F9A324B/100"
["is_yellow_vip"] => string(1) "0"
["vip"] => string(1) "0"
["yellow_vip_level"] => string(1) "0"
["level"] => string(1) "0"
["is_yellow_year_vip"] => string(1) "0"
}
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
