为了账号安全,请及时绑定邮箱和手机立即绑定

网页授权 用getUserDetail方法时会出现俩错误 40029 和41001,总是说code无效,谁知道为什么

public function getUserDetail(){
        //获取code
        $appId=$this->_appID;
        $redirectUrl='http://www.wangying.online/wxtest/index.php?s=Home/Index/getUserInfo';
        $url='https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$appId.'&redirect_uri='.$redirectUrl.'&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect';
        header('location:'.$url);
    }
    //获取用户详细信息
    public function getUserInfo() {
        $appId=$this->_appID;
        $appSecret=$this->_appsecret;
        $code=$_GET['code'];
        //var_dump($code);exit;
        $url='https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$appId.'&secret='.$appSecret.'&code='.$code.'&grant_type=authorization_code ';
        $res=$this->http_curl($url,'get');
        var_dump($res);
        $access_token=$res['access_token'];
        $openid=$res['openid'];
        $url='https://api.weixin.qq.com/sns/userinfo?access_token='.$access_token.'&openid='.$openid.'&lang=zh_CN';
        $res=$this->http_curl($url);
        var_dump($res); 
    }


正在回答

5 回答

http://img1.sycdn.imooc.com//583a82080001a14715800998.jpg

答案如图

0 回复 有任何疑惑可以回复我~
#1

baleful 提问者

非常感谢!
2016-11-30 回复 有任何疑惑可以回复我~

我的确实是这个问题,多谢了,

0 回复 有任何疑惑可以回复我~

只能通过snspai_base就好了

1 回复 有任何疑惑可以回复我~
#1

想进村的王师傅

我也是啊= =不过这俩有什么区别吗base 和 userinfo
2016-10-22 回复 有任何疑惑可以回复我~

通过snsapi_userinfo就是返回40029错误,获取不到access_token,你解决了吗

0 回复 有任何疑惑可以回复我~

没太明白

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

网页授权 用getUserDetail方法时会出现俩错误 40029 和41001,总是说code无效,谁知道为什么

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号