助力软件开发企业降本增效 PHP / java源码系统,只需一次付费,代码终身使用! 广告
``` public function text(){ $code= I('get.code');//用户的登录凭证code(使用wx.login({})可获取到)这个是前端传过来 $appid='小程序的appid'; $secret='密钥就是secret'; $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); echo json\_encode($array); } ```