获取自定义菜单查询返回的结果有乱码
解决方法:
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);
以上就是微信开发--自定义菜单查询乱码破解法的详细内容,更多请关注二当家的素材网其它相关文章!
友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群