Home  >  Article  >  WeChat Applet  >  WeChat development--Custom menu query garbled code cracking method

WeChat development--Custom menu query garbled code cracking method

高洛峰
高洛峰Original
2017-03-11 15:29:191683browse

This article mainly introduces WeChat development-the solution to the garbled code returned by custom menu query, which has a very good reference value. Let’s take a look at it with the editor

The results returned by getting the custom menu query are garbled

Solution:


string Posturl = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=Token";
//设置提交的相关参数
HttpWebRequest request = WebRequest.Create(Posturl) as HttpWebRequest;
//提交方式
request.Method = "Get";
//编码格式
request.ContentType = "text/html;charset=UTF-8";
HttpWebResponse respone = (HttpWebResponse)request.GetResponse();
StreamReader stream = new StreamReader(respone.GetResponseStream(), Encoding.UTF8);
string jsonstring = stream.ReadToEnd();

The final result will be garbled. Use UTF8 when decoding the stream.

StreamReader stream = new StreamReader(respone.GetResponseStream(), Encoding.UTF8 );

The above is the detailed content of WeChat development--Custom menu query garbled code cracking method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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