网站调用新浪微博内容( 【C#小蜗牛】C#调用微博API的相关知识点内容)

优采云 发布时间: 2022-01-15 10:02

  网站调用新浪微博内容(

【C#小蜗牛】C#调用微博API的相关知识点内容)

  C#调用新浪微博API示例代码

  更新时间:2019年11月11日15:01:10 作者:肖小蜗牛

  在这篇文章中,小编整理了一篇关于C#调用微博API的知识。需要的朋友可以学习一下。

  C#调用新浪微博API

  

WebRequest wq = WebRequest.Create(this.address);

HttpWebRequest hq = wq as HttpWebRequest;

string username = "keguangqiang@163.com";

string password = "3216731ks";

string a*敏*感*词*ey = "5786724301";

System.Net.CredentialCache cache = new CredentialCache();

cache.Add(new Uri(this.address), "Basic", new NetworkCredential(username, password));

hq.Credentials = cache;

hq.Headers.Add("Authorization","Basic " +Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes(username+":"+password)));

System.Net.WebResponse webresponse = hq.GetResponse();

System.IO.Stream receiveStream = webresponse.GetResponseStream();

System.IO.StreamReader reader = new System.IO.StreamReader(receiveStream, System.Text.Encoding.UTF8);

string json = reader.ReadToEnd();

  

  上面的代码示例很简单,可以在本地测试,感谢大家对Scripting Home的阅读和支持。

0 个评论

要回复文章请先登录注册


官方客服QQ群

微信人工客服

QQ人工客服


线