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);