想要用腾讯官方封的类就必须对其进行修改,修改如下:
当然这快我是改好了
申请教程:https://www.yxxxm.com/article/95.shtml
申请地址:https://connect.qq.com/index.html
直接点击下载就好了.
安装教程
-
下载代码
-
创建目录kuange
-
代码复制kuange下
-
放置extend下
使用说明
-
此包有tp5辅助函数其他框架需修改
-
配置config.php
'qqconnect' => [
'appid' => '101503005',
'appkey' => 'd41323d9e8fa91d78c24582d8d897ec1',
'callback' => 'https://www.yxxxm.com/qq_login',
'scope' => 'get_user_info,add_share,list_album,add_album,upload_pic,add_topic,add_one_blog,add_weibo,check_page_fans,add_t,add_pic_t,del_t,get_repost_list,get_info,get_other_info,get_fanslist,get_idolist,add_idol,del_idol,get_tenpay_addr',
'errorReport' => true
]
- 代码demo
class Oauth extends Controller
{
public function qq()
{
$qc = new QC();
return redirect($qc->qq_login());
}
public function qq_login()
{
$qc = new QC();
$access_token = $qc->qq_callback();
$openid = $qc->get_openid();
// qq互联请求地址
// https://graph.qq.com/user/get_user_info?access_token=YOUR_ACCESS_TOKEN&oauth_consumer_key=YOUR_APP_ID&openid=YOUR_OPENID
$user = json_decode($this->CurlGet("https://graph.qq.com/user/get_user_info?access_token=" . $access_token . "&oauth_consumer_key=" . Config('qqconnect.appid') . "&openid=" . $openid));
$nickname = $user->{'nickname'};
$figureurl_qq_2 = $user->{'figureurl_qq_2'};
TODO代码逻辑.....
}
//get请求
function CurlGet($url)
{
return $this->CurlPost($url, "");
}
//curl 的post请求
function CurlPost($url, $data)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
curl_setopt($curl, CURLOPT_URL, $url);
if (!empty($data)) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}```
网友评论