解决方法:
1
2
3
4
5
6
7
8
9
10
|
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);
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持服务器之家!
原文链接:http://www.cnblogs.com/zhyue93/p/WeiXin_GetMenu.html