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();
以上代码实例很简单,大家可以本地测试下,感谢你的阅读和对的支持。
上一篇: VS2019打包WPF安装程序最新教程(图文详解)
下一篇: C#如何控制IIS动态添加删除网站详解