zoukankan      html  css  js  c++  java
  • 使用iwebshop開發實現QQ第三方登錄

     1 $appid = "101353491";
     2 
     3        $appkey = "df4e46ba7da52f787c6e3336d30526e4";
     4 
     5        $redirect_uri = "http://www.iwebshop.com/index.php";
     6        $redirect_uri = urlencode($redirect_uri);
     7        $url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id={$appid}&redirect_uri={$redirect_uri}&state=123";
     8        $code = $_GET['code'];
     9        //通过Authorization Code获取Access Token
    10        $acurl = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id={$appid}&client_secret={$appkey}&code={$code}&redirect_uri={$redirect_uri}";
    11        $acstr = file_get_contents($acurl);
    12        $acarr = explode('&',$acstr);
    13        $acstr = explode('=',$acarr[0]);
    14        $access_token = $acstr[1];
    15        $opurl = "https://graph.qq.com/oauth2.0/me?access_token={$access_token}";
    16        $oparr = file_get_contents($opurl);
    17        $opstr = substr($oparr,10);
    18        $opstr = substr($opstr,0,-4);
    19        $opstr = json_decode($opstr,true);
    20        $openid = $opstr['openid'];
    21        $userinfourl = "https://graph.qq.com/user/get_user_info?access_token={$access_token}&oauth_consumer_key={$appid}&openid={$openid}";
    22        $userinfo = file_get_contents($userinfourl);
    23        echo "<pre>";
    24        var_dump($userinfo);
  • 相关阅读:
    如何使用PL/SQL工具批量导出表、存储过程、序列
    oracle如何导出和导入数据库/表
    linux安装nginx
    Linux下nginx反向代理服务器安装与配置实操
    StringTokenizer
    mapreduce join
    mapreduce计数器
    hadoop分布式系统架构详解
    进程与线程
    hadoop第一个例子
  • 原文地址:https://www.cnblogs.com/songbao/p/11226285.html
Copyright © 2011-2022 走看看