网站调用新浪微博内容( 【C#小蜗牛】C#调用微博API的相关知识点内容)
优采云 发布时间: 2021-10-31 13:04网站调用新浪微博内容(
【C#小蜗牛】C#调用微博API的相关知识点内容)
C#Invoke 新浪微博 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();
上面的代码示例非常简单。您可以在本地进行测试。感谢您阅读和支持脚本之家。