我是靠谱客的博主 聪慧背包,这篇文章主要介绍C#调用新浪微博API实例代码,现在分享给大家,希望可以做个参考。

C#调用新浪微博API

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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实例代码的全部内容,更多相关C#调用新浪微博API实例代码内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(116)

评论列表共有 0 条评论

立即
投稿
返回
顶部