PHP开发微信自定义菜单不转义中文的方法

WBOY
Release: 2016-06-20 12:52:38
Original
1018 people have browsed it

接口文档说明:
http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html

按照文档走,使用php执行,结果:
{"errcode":40033,"errmsg":"invalid charset. please check your request, if include \uxxxx will create fail!"}

上网查询资料,结果显示:
如果php的版本在5.4+:
$menu = json_encode($menuStr, JSON_UNESCAPED_UNICODE);

否则:
$menu = json_encode($menuStr, JSON_UNESCAPED_UNICODE);
$menu = urldecode($menu);

菜单中有中文的时候这样处理,不会转义汉字,也就不会报错了.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!