使用iwebshop開發實現QQ第三方登錄
2024-10-07 06:04:13
$appid = "101353491"; $appkey = "df4e46ba7da52f787c6e3336d30526e4"; $redirect_uri = "http://www.iwebshop.com/index.php";
$redirect_uri = urlencode($redirect_uri);
$url = "https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id={$appid}&redirect_uri={$redirect_uri}&state=123";
$code = $_GET['code'];
//通过Authorization Code获取Access Token
$acurl = "https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&client_id={$appid}&client_secret={$appkey}&code={$code}&redirect_uri={$redirect_uri}";
$acstr = file_get_contents($acurl);
$acarr = explode('&',$acstr);
$acstr = explode('=',$acarr[0]);
$access_token = $acstr[1];
$opurl = "https://graph.qq.com/oauth2.0/me?access_token={$access_token}";
$oparr = file_get_contents($opurl);
$opstr = substr($oparr,10);
$opstr = substr($opstr,0,-4);
$opstr = json_decode($opstr,true);
$openid = $opstr['openid'];
$userinfourl = "https://graph.qq.com/user/get_user_info?access_token={$access_token}&oauth_consumer_key={$appid}&openid={$openid}";
$userinfo = file_get_contents($userinfourl);
echo "<pre>";
var_dump($userinfo);
最新文章
- C#调用百度高精度IP定位API通过IP获取地址
- Red Gate(SQLToolbelt)SQL Server的安装与注册(破解)
- Winodow Server Backup学习向导-window 2008
- HOLOLENS的DEVICE POTAL连接和安装
- ionic cordova 热更新
- 通信vue2.0组件
- vbox共享文件 挂载
- Synchronized及其实现原理
- Http状态总结
- Android 通过程序添加桌面快捷方式
- Android之界面刷新(invalidate和postInvalidate使用)
- PHP 获取文件权限函数
- android map高德地图显示多个点,并且每个marker点可以响应鼠标点击事件,处理跳转页面
- HDU 4633 Who&#39;s Aunt Zhang (Polya定理+快速幂)
- javascript获取浏览器窗口大小办法
- Coding the Matrix Week 1 The Vector Space作业
- 用备份控制文件做不完全恢复下的完全恢复(数据文件备份<;旧>;--新建表空间--控制文件备份<;次新>;--日志归档文件<;新>;)
- Mongo 专题
- MySQL skip-character-set-client-handshake导致的一个字符集问题
- Project Euler Problem9