tp代码:
//用户授权注册
//https://yanyu-shop.lonelygod.work/api/user/codes
public function codes()
{
$code = input('code');
//用户的登录凭证code(使用wx.login({})可获取到)这个是前端传过来
$appid = 'wxf**45';
$secret = '53e**e39';
$url = "https://api.weixin.qq.com/sns/jscode2session?appid=$appid&secret=$secret&js_code=$code&grant_type=authorization_code";
$weixin = file_get_contents($url);
$jsondecode = json_decode($weixin);
$array = get_object_vars($jsondecode);
return json($array);
}