您好,登錄后才能下訂單哦!
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();
以上代碼實例很簡單,大家可以本地測試下,感謝你的閱讀和對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。