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

PHP获取小程序用户openid

时间:2020-07-28 13:50:47      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:nts   style   注册   api   type   php   code   pen   http   

代码如下:

//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};

 

PHP获取小程序用户openid

标签:nts   style   注册   api   type   php   code   pen   http   

原文地址:https://www.cnblogs.com/xihailong/p/13390109.html

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