微信公众号自定义菜单
官方文档   https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html
 
很简单的一个接口调用,但是当有中文菜单名的就可能出现下面2个错误
 
{“errcode”:40016,”errmsg”:”invalid button size”} 
{“errcode”:40033,”errmsg”:”invalid charset. please check your request, if include \uxxxx will create fail!”}
 
原因是php的json_encode函数将中文转为了 unicode 格式,但是微信要求不能有\uxxx格式的字符,所以会报错
 
解决办法,PHP 5.4之后json_encode新增了一个参数JSON_UNESCAPED_UNICODE,不转中文为unicode
posted on 2019-12-05 16:05  ljstu  阅读(395)  评论(0编辑  收藏  举报