微信oAuth授权返回处理
时间:2015-01-22 17:37:32
收藏:0
阅读:503
$wechat_accesstoken = $wechat_domain."oauth2/access_token?appid=".APPID."&secret=".SECRET."&code=".$code."&grant_type=authorization_code"; $r = httpsget($wechat_accesstoken); $a = json_decode($r,true); $accesstoken = $a[‘access_token‘]; //$refresh_token = $a[‘refresh_token‘]; $openid = $a[‘openid‘]; //拉取用户信息 $wechat_user = $wechat_domain."userinfo?access_token=".$accesstoken."&openid=".$openid."&lang=zh_CN"; $r = httpsget($wechat_user); $a = json_decode($r,true);
//a 的内容如下 $a = array( ‘nickname‘=>$a[‘nickname‘], ‘sex‘=>$a[‘sex‘], ‘province‘=>$a[‘province‘], ‘city‘=>$a[‘city‘], ‘country‘=>$a[‘country‘], ‘headimgurl‘=>$a[‘headimgurl‘], ‘privilege‘=>json_encode($a[‘privilege‘]), ‘unionid‘=>$a[‘unionid‘] );
评论(0)