美文网首页
tp5怎么实现QQ第三方登录

tp5怎么实现QQ第三方登录

作者: LauEl | 来源:发表于2018-12-16 23:21 被阅读149次

    想要用腾讯官方封的类就必须对其进行修改,修改如下:

    当然这快我是改好了

    申请教程:https://www.yxxxm.com/article/95.shtml

    申请地址:https://connect.qq.com/index.html

    直接点击下载就好了.

    百度云盘 码云

    安装教程

    1. 下载代码

    2. 创建目录kuange

    3. 代码复制kuange下

    4. 放置extend下

    使用说明

    1. 此包有tp5辅助函数其他框架需修改

    2. 配置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
        ]
    
    1. 代码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;
        }```

    相关文章

      网友评论

          本文标题:tp5怎么实现QQ第三方登录

          本文链接:https://www.haomeiwen.com/subject/axyfkqtx.html