微信开发 自定义菜单查询 返码乱码
获取自定义菜单查询返回的结果有乱码
解决方法:
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);