欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-06-09 10:11:35
c#调用新浪微博api webrequest wq = webrequest.create(this.address); httpwebrequest hq = wq as...

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实例代码

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