软件编程
位置:首页>> 软件编程>> C#编程>> C#调用新浪微博API实例代码

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

作者:XIAO小蜗牛  发布时间:2022-12-21 14:02:15 

标签:C#,微博,API

C#调用新浪微博API


WebRequest wq = WebRequest.Create(this.address);
HttpWebRequest hq = wq as HttpWebRequest;

string username = "keguangqiang@163.com";
string password = "3216731ks";
string appkey = "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();

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

以上代码实例很简单,大家可以本地测试下,感谢你的阅读和对脚本之家的支持。

来源:https://www.cnblogs.com/keguangqiang/p/3315210.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com