设置微信公众号的测试号的菜单流程可参考https://blog.csdn.net/hqsary/article/details/82347862
现在着重要说的是其中接口配置信息的处理
1:自定义一个接口(GET类型),填入URL输入框
2:在接口逻辑中获取参数(微信调用传过来参数)echostr【每次传输值可能不一样】
3:在接口逻辑中返回这个参数(echostr)的值给调用者(微信)
注:token 输入框作用:
用于校验微信给到的参数是否和你填入的token是否一致【可不用校验】
用node+postman简易流程
1.node代码
// 微信测试账号校验
app.get('/weixin/auth', (req, res) => {
res.send(req.query.echostr || '')
})
2.获取access_token
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=appid&secret=secret
3.创建菜单
https://api.weixin.qq.com/cgi-bin/menu/create?access_token=access_token
// 菜单参数
{
"button":[
{
"type":"view",
"name":"投资顾问版",
"key":"TOUGU",
"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appid&redirect_uri=redirect_uri&response_type=code&scope=snsapi_base#wechat_redirect"
},
{
"type":"view",
"name":"业主版",
"key":"TOUGU",
"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appid&redirect_uri=redirect_uri&response_type=code&scope=snsapi_base#wechat_redirect"
},
{
"type":"view",
"name":"客户版",
"key":"KEHU",
"url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appid&redirect_uri=redirect_uri&response_type=code&scope=snsapi_base#wechat_redirect"
}
]
}