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.