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

微信公众号开发笔记1-获取Access Token

发布时间:2020-12-14 17:06:22 所属栏目:资源 来源:网络整理
导读:获取你的Access Token a)可以采用网址的形式: 用appid和appsecert获得access token,接口为https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credentialappid=你的APPIDsecret=你的APPSECRET 替换中间的你的APPID和APPSECRET。 b)也可以采用代

获取你的Access Token

 a)可以采用网址的形式:

  用appid和appsecert获得access token,接口为https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=你的APPID&secret=你的APPSECRET

  替换中间的你的APPID和APPSECRET。

 b)也可以采用代码的形式:

$appid = "";
$appsecret = ""$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt(FALSE); 
curl_setopt();
$output = curl_exec($ch);
curl_close($jsoninfo = json_decode($output,1)">true$access_token = $jsoninfo["access_token"];

?

? ?c)你也可以直接在浏览器地址栏中,拼接出地址,执行后,获得如下数据

{"access_token":"N2L7KXa084WvelONYjkJ_traBMCCvy_UKmpUUzlrQ0EA2yNp3Iz6eSUrRG0bhaR_viswd50vDuPkY5nG43d1gbm-olT2KRMxOsVE08RfeD9lvK9lMguNG9kpIkKGZEjIf8Jv2m9fFhf8bnNa-yQH3g","expires_in":7200}

  参数说明如下

参数

说明

access_token

获取到的凭证

expires_in

凭证有效时间,单位:秒

  其中的N2L7KXa084WvelONYjkJ_traBMCCvy_UKmpUUzlrQ0EA2yNp3Iz6eSUrRG0bhaR_viswd50vDuPkY5nG43d1gbm-olT2KRMxOsVE08RfeD9lvK9lMguNG9kpIkKGZEjIf8Jv2m9fFhf8bnNa-yQH3g

就是access token。

 d)或者使用官方的接口调试工具,地址为:

  使用网页调试工具调试自定义菜单接口?

  点击检查问题得,得到原文?http://www.cnblogs.com/txw1958/p/weixin-58-custom-menu.html?

  这样也获得了access token

?

(编辑:李大同)

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

    推荐文章
      热点阅读