php微信發(fā)送推送消息亂碼的解決辦法:首先中文在數(shù)組轉(zhuǎn)json時會被編碼為unicode,使用urlencode識別微信接口;然后在【json_encode】前進(jìn)行編碼;最后等轉(zhuǎn)換后再用urldecode轉(zhuǎn)回來即可。
php微信發(fā)送推送消息亂碼的解決辦法:
先用urlencode是因為中文在數(shù)組轉(zhuǎn)json時會被編碼為unicode,微信接口無法識別,所以得在json_encode前先來個編碼,等轉(zhuǎn)換后再用urldecode轉(zhuǎn)回來,這樣傳輸給接口的就是正常的中文了。
參考代碼:
$message = array( 'touser'=>$touser, 'msgtype'=>'text', 'text'=>array('content'=>urlencode($text)));$message = urldecode(json_encode($message));相關(guān)學(xué)習(xí)推薦:php圖文教程