加入收藏 | 设为首页 | 会员中心 | 我要投稿 北几岛 (https://www.beijidao.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

PHP利用微信跳转的Code参数获取用户的openid

发布时间:2021-07-06 06:47:45 所属栏目:大数据 来源: https://www.jb51.cc
导读://获取微信登录用户信息 function getOpenID($appid,$appsecret,$code){ ? ??$url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid."secret=". ???????????? $appsecret."code=".$code."grant_type=authorization_code"; ???? $weixin=f

//获取微信登录用户信息
function getOpenID($appid,$appsecret,$code){
?
??$url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid."&secret=".
???????????? $appsecret."&code=".$code."&grant_type=authorization_code";
???? $weixin=file_get_contents($url);//通过code换取网页授权access_token
??????? $jsondecode=json_decode($weixin); //对JSON格式的字符串进行编码
??????? $array = get_object_vars($jsondecode);//转换成数组
??????? $openid = $array['openid'];//输出openid
??????? return $openid;
????? }

(编辑:北几岛)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读