新路线之微信公众号开发

首先是添加菜单。

OutTextMsg outMsg = new OutTextMsg(inTextMsg);

String str = "{" +
" \"button\":[{" +
" \"type\":\"view\"," +
" \"name\":\"我要收款\"," +
" \"url\":\"https://www.baidu.com\"" +
" },{" +
" \"type\":\"view\"," +
" \"name\":\"卡友俱乐部\","+
" \"url\":\"https://www.baidu.com\"" +
" },{" +
" \"type\":\"view\"," +
" \"name\":\"管理中心\"," +
" \"url\":\"https://www.baidu.com\"" +
" }]" +
" }";
ApiResult apiResult = MenuApi.createMenu(str);

if (apiResult.isSucceed()) {
outMsg.setContent(apiResult.getJson());
} else {
outMsg.setContent(apiResult.getErrorMsg());
}
render(outMsg);


以上半代码没问题。但是却修改不成功。一直报 获取access_token时AppSecret错误,或者access_token无效

网上搜索结果并不能成功修改。于是查看控制台,出现"errcode":40164,"errmsg":"invalid ip 000.000.00.0, not in whitelist hint: [xxxxxx]"}

这个是因为 公众号白名单设置问题。
在公众号的 开发-基本设置-白名单设置即可。

然后在怎么修改都不变。后来发现 只要删除菜单才重新添加即可。

还有就是因为公众号有缓存,官方说的是24小时刷新。但是有的是说的5分钟。具体米有测试。所以需要重新关注公众号就可以马上刷新

公众号开发测试。因为公众号那里需要绑定服务器地址。所以如果在本地调试的话 需要一个内网穿透工具。。不足的就是。那个地址每次重启都会刷新。修改不太方便

  

posted @ 2018-12-11 10:00  mogic  阅读(302)  评论(0编辑  收藏  举报