WeChat publishing menu failed

Source: Internet
Author: User
Take out the http_post request in the interface, send the request separately, and generate the menu. However, the menu for creating letters can be published successfully. If a Chinese character is created, a message indicating a publishing failure is displayed. The system reports a 40033 error. invalid request characters cannot contain characters in uxxxx format. Why is this? Take out the http_post request in the interface, send the request separately, and generate the menu. However, the menu for creating letters can be published successfully. If a Chinese character is created, a message indicating a publishing failure is displayed. The error 40033 is returned. invalid request characters cannot contain characters in \ uxxxx format. This is why. You can use createMenu in the interface to publish all files.

Reply content:

Take out the http_post request in the interface, send the request separately, and generate the menu. However, the menu for creating letters can be published successfully. If a Chinese character is created, a message indicating a publishing failure is displayed. The error 40033 is returned. invalid request characters cannot contain characters in \ uxxxx format. This is why. You can use createMenu in the interface to publish all files.

php/*** The api does not support json structure escaped from Chinese characters * @ param array $ arr */static function json_encode ($ arr) {$ parts = array (); $ is_list = false; // Find out if the given array is a numerical array $ keys = array_keys ($ arr); $ max_length = count ($ arr)-1; if ($ keys [0] === 0) & ($ keys [$ max_length] ===$ max_length )) {// See if the first key is 0 and last key is length-1 $ is_list = true; for ($ I = 0; $ I <count ($ ke Ys); $ I ++) {// See if each key correspondes to its position if ($ I! = $ Keys [$ I]) {// A key fails at position check. $ is_list = false; // It is an associative array. break ;}}foreach ($ arr as $ key =>$ value) {if (is_array ($ value) {// Custom handling for arrays if ($ is_list) $ parts [] = self: json_encode ($ value);/*: RECURSION: */else $ parts [] = '"'. $ key. '":'. self: json_encode ($ value);/*: RECURSION: */} else {$ str = ''; if (! $ Is_list) $ str = '"'. $ key. '":'; // Custom handling for multiple data types if (is_numeric ($ value) & $ value <2000000000) $ str. = $ value; // Numbers elseif ($ value = false) $ str. = 'false'; // The booleans elseif ($ value = true) $ str. = 'true'; else $ str. = '"'. addslashes ($ value ). '"'; // All other things //: TODO: Is there any more datatype we shoshould be in the lookout? (Object ?) $ Parts [] = $ str ;}$ json = implode (',', $ parts); if ($ is_list) return '['. $ json. ']'; // Return numerical JSON return '{'. $ json. '}'; // Return associative JSON}

See wechat-php-sdk

You can concatenate A json string directly. Why do you need arrays and encode.

Json is more intuitive.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.