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);
  • 相关阅读:
    JVM 调优工具
    JVM tomcat 性能调优
    meven 新建web 项目
    垃圾收集器
    JVM 内存溢出
    JVM 常见参数配置
    垃圾回收机制策略
    MongoDB C#驱动:
    基于MSMQ绑定的WCF服务实现总结
    python _、__和__xx__的区别(转)
  • 原文地址:https://www.cnblogs.com/songbao/p/11226285.html
Copyright © 2011-2022 走看看