码迷,mamicode.com
首页 > 微信 > 详细

微信oAuth授权返回处理

时间:2015-01-22 17:37:32      阅读:503      评论:0      收藏:0      [点我收藏+]

标签:

   $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‘] );

 

微信oAuth授权返回处理

标签:

原文地址:http://www.cnblogs.com/xueyuwyz/p/4241862.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!