TP5微信小程序获取access_token
2021/6/21 12:26:05
本文主要是介绍TP5微信小程序获取access_token,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
protected $appid = 'xxxxxxxxxxxxxxxxx'; protected $appsecrt = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; public function getSessionKey() { //获取access_token //获取openID $code = $this->request->param('code'); if($code) { $token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$this->appid."&secret=".$this->appsecrt; $str_token = file_get_contents($token); $json_token = json_decode($str_token); $arr_token = get_object_vars($json_token); $this->success('获取成功',['access_token'=>$arr_token['access_token']],'20000'); }else{ $this->error('获取失败,code不存在','','20001'); } }
这篇关于TP5微信小程序获取access_token的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-19微信小程序项目中miniprogram_npm文件跟node_modules文件的差别-icode9专业技术文章分享
- 2024-08-27小程序 单行显示,超出部分省略号显示的方法代码-icode9专业技术文章分享
- 2024-08-27微信小程序如何获取到特种设备的刘海屏高度-icode9专业技术文章分享
- 2024-08-27微信小程序如何获取苹果手机底部一横线高度信息方法代码-icode9专业技术文章分享
- 2024-08-27微信小程序 顶部状态栏标签背景为none但还是看不到状态栏什么原因-icode9专业技术文章分享
- 2024-08-21微信小程序全栈入门:从零开始的一站式指南
- 2024-08-21微信小程序入门:轻松打造你的第一款小程序
- 2024-08-10如何实现在微信小程序内卖药?线上药店商城小程序怎么做?
- 2024-08-08uniapp小程序无痛刷新token方法-icode9专业技术文章分享
- 2024-08-08在小程序中使用canvas绘制两个可拖拽交换位置的单元格代码示例-icode9专业技术文章分享