C#调用新浪微博API实例代码
程序员文章站
2023-10-31 13:37:16
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();
以上代码实例很简单,大家可以本地测试下,感谢你的阅读和对的支持。
上一篇: 胃病如何食补比较好