PHP获取小程序用户openid
时间:2020-07-28 13:50:47
收藏:0
阅读:101
代码如下:
//code值,从前端获取 $code = $_GET[‘code‘]; //注册时获取 $appid="xxxxxxxxxxxxx"; $secret = "xxxxxxxxxxxxxxxxxxxxx"; $get_code_url = ‘https://api.weixin.qq.com/sns/jscode2session?appid=‘.$appid.‘&secret=‘.$secret.‘&js_code=‘.$code.‘&grant_type=authorization_code‘; $ret=file_get_contents($get_code_url); $openid= json_decode($ret)->{‘openid‘};
评论(0)