记一次php获取微信用户

前面的步骤都可以按照官方文档的来,我的问题出在了获取access_token..

我一直在纠结如何取到这个access_token,用ajax一直都取不到,可能是微信为了安全。

后来运用了这个就取到了

  $weixin=file_get_contents("https://api.weixin.qq.com/sns/oauth2/access_token?appid=xxxxxxxxx&secret=xxxxxxxxx&code=".$code."&grant_type=authorization_code");
        $jsondecode=json_decode($weixin);
        $array=get_object_vars($jsondecode);
        $access_token=$array['access_token'];
        $openid=$array['openid'];

猜你喜欢

转载自blog.csdn.net/qq_37034181/article/details/82818052
今日推荐