創建菜單我們可以使用微信提供的工具進行生成
- 如何獲取access_token
每次獲取的access_token有效時間為7200s,超過這個時間,如果想重置菜單,需要按照下面的方法重新獲取一次,再次操作。
使用如下的網址(<b>注意替換自己的AppID,AppSecret</b>)獲取https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=AppID&secret=AppSecret
AppID:測試申請的界面中的appId
AppSecret:測試申請界面的appsecret
打開如上網址可以獲取包含access_token的json串,復制其中的access_token即可
* 使用JSON生成菜單
{
"button": [
{
"type": "click",
"name": "今日歌曲",
"key": "V1001_TODAY_MUSIC"
},
{
"name": "菜單",
"sub_button": [
{
"type": "view",
"name": "搜索",
"url": "http://www.soso.com/"
},
{
"type": "view",
"name": "視頻",
"url": "http://v.qq.com/"
},
{
"type": "click",
"name": "贊一下我們",
"key": "V1001_GOOD"
}
]
}
]
}
* 生成菜單會不會立即生效,可以取消關注后,再重新關注即可看到