2 yuhaozyx yuhaozyx 于 2013.07.28 18:52 提问

C#获取访问网页Json数据

使用http://r.qzone.qq.com/cgi-bin/tfriend/friend_mngfrd_get.cgi?uin=441212678&rd=0.3932640394195914&g_tk=450427580&fupdate=1类似的代码可以返回QQ好友列表的Json数据,一个笨的办法是Ctrl+A全选复制然后粘贴到记事本中再进行进一步处理,我想让HttpWebRequest对象获取返回的数据字符串,比如(
{"items":[{"uin":14377775,
"groupid":0,
"name":"陈建刚",
"is_special":"0",
......
)代码如下
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream ResStream = response.GetResponseStream();
Encoding encoding = Encoding.GetEncoding("GBK2312");
StreamReader streamReader = new StreamReader(ResStream, encoding);
MessageBox.Show(streamReader.ReadToEnd());
结果却如下很郁闷,请大家帮我看看,我想返回的是Json数组!!是不是要添加缓存信息什么的?求指点!
_Callback({
"code":-3000,
"subcode":-4001,
"message":"璇峰厛鐧诲綍銆?,
"notice":0,
"time":1375008469,
"tips":"80CB-1705"
}
);

1个回答

wangqiuyun
wangqiuyun   2015.10.12 17:52

亲,这是跨域的jsonp回调方式,你把_Callback()去掉,里面就是标准的json了

Csdn user default icon
上传中...
上传图片
插入图片