获取自定义菜单查询返回的结果有乱码
解决方法:
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();
最后结果就没乱码了,流解码的时候要用UTF8
StreamReader stream = new StreamReader(respone.GetResponseStream(), Encoding.UTF8);
以上就是微信开发--自定义菜单查询乱码破解法的详细内容,更多请关注php中文网其它相关文章!