• QQ登录


        public function login(){
            $urlencode = urlencode("http://www.zhangxuhui.com/index/Index/callback");
            $url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=XXXXXXXX&redirect_uri={$urlencode}&state=shop";
            $data = compact("url");
            return view("",$data);
        }
        // 回调地址
        public function callback($code){
            // 1.获取code
            // 2.发起请求 获取access_token
            $urlencode = urlencode("http://www.zhangxuhui.com/index/Index/callback");
            $url = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id=XXXXXXX&client_secret=YYYYYYYYYYYY&code={$code}&redirect_uri={$urlencode}&fmt=json";
            $json = file_get_contents($url);
            $obj = json_decode($json);
            $access_token = $obj->access_token;
            // 3.发起请求 获取openid
            $url = "https://graph.qq.com/oauth2.0/me?access_token={$access_token}&fmt=json";
            $obj = json_decode(file_get_contents($url));
            $openid = $obj->openid;
            // 4.获取用户的信息
            $url = "https://graph.qq.com/user/get_user_info?access_token={$access_token}&oauth_consumer_key=XXXXXXXXX&openid={$openid}";
            dump(file_get_contents($url));
            // 1.qq_member表写入数据,id,openid,nickname,gender,login_num,mid
    
            // 2.写session
    
            // 3. 跳转到首页
    
        }
    

    本文来自博客园,作者:公子初心,转载请注明原文链接:https://www.cnblogs.com/itzhangxuhui/p/15728008.html

  • 相关阅读:
    mysql字符集设置
    mysql解压版服务启动方式
    html的表格边框为什么会这么粗?
    通过js获取tinymce4.x的值
    bzoj 3083 树链剖分
    bzoj 1143 二分图最大独立集
    bzoj 2303 并查集
    可持久化数据结构讲解
    bzoj 1072 状压DP
    bzoj 2741 可持久化trie
  • 原文地址:https://www.cnblogs.com/itzhangxuhui/p/15728008.html
Copyright © 2020-2023  润新知