public static string GetResult(string url)
{
string username = "账户";
string password = "密码";
string usernamePassword = username + ":" + password;
WebRequest webRequest = WebRequest.Create(url);
HttpWebRequest myReq = webRequest as HttpWebRequest;
CredentialCache myCache = new CredentialCache();
myCache.Add(new Uri(url), "Basic", new NetworkCredential(username, password));
myReq.Credentials = myCache;
myReq.Headers.Add("Authorization", "Basic " +
Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes(usernamePassword)));
WebResponse wr = myReq.GetResponse();
Stream receiveStream = wr.GetResponseStream();
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
return reader.ReadToEnd();
} public static string GetResult(string url)
{
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
string str = string.Empty;
try
{
str = client.DownloadString(url);
}
catch
{
throw;
}
finally
{
client.Dispose();
}
return str;
}两个方法都不行,comments/show.json不能获取数据,但users/show.json和user_timeline.json可以获取,用的是ipad版微博的key,为什么同样是需要登录的,获取评论就不行,求助啊api
{
string username = "账户";
string password = "密码";
string usernamePassword = username + ":" + password;
WebRequest webRequest = WebRequest.Create(url);
HttpWebRequest myReq = webRequest as HttpWebRequest;
CredentialCache myCache = new CredentialCache();
myCache.Add(new Uri(url), "Basic", new NetworkCredential(username, password));
myReq.Credentials = myCache;
myReq.Headers.Add("Authorization", "Basic " +
Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes(usernamePassword)));
WebResponse wr = myReq.GetResponse();
Stream receiveStream = wr.GetResponseStream();
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
return reader.ReadToEnd();
} public static string GetResult(string url)
{
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
string str = string.Empty;
try
{
str = client.DownloadString(url);
}
catch
{
throw;
}
finally
{
client.Dispose();
}
return str;
}两个方法都不行,comments/show.json不能获取数据,但users/show.json和user_timeline.json可以获取,用的是ipad版微博的key,为什么同样是需要登录的,获取评论就不行,求助啊api
解决方案 »
- asp.net操作excel里面的控件
- 常规数据库空间规范下的几种构架分别有什么作用?
- 帮忙看看
- Button类的按钮能实现Click事件中的程序代码,为什么LinkButton实现不了,为什么?
- 在ASP.NET中如何实现server到browser的自动回传??急
- 在TextBox中按回车键,为什么自动执行了本该按某按钮才能执行的功能。
- aspx.cs中如何引用用户控件中的属性
- 百分求解可重用代码问题--第二版
- 取datatable中的两列
- DropDownList中怎么取得已知数据的索引值---太简单了,来抢分啊!!!!
- jquery $get请求时,返回数据问题
- SlickUpload6.1.7 自定义文件名和文件路经的实现?
嗯,sdk很全的。不愧是大网站,关注的人也多。