新浪微博如何通过获取的 oauth_token oauth_token_secret 发送微博信息
如:
oauth_token=a593cf5e531efd1219fbca9b0a62f654&oauth_token_secret=d3f69686b4446f19f348cc0503b90958&user_id=2155022943
如:
oauth_token=a593cf5e531efd1219fbca9b0a62f654&oauth_token_secret=d3f69686b4446f19f348cc0503b90958&user_id=2155022943
{
string username = "[email protected]";
string password = "000000";
string usernamePassword = username + ":" + password; //准备调用的URL及需要POST的数据: string url = "http://api.t.sina.com.cn/statuses/update.xml?source=" + ConfigurationManager.AppSettings["WB_AKEY"];
string content = "新的一天新的开始!";
string data ="status=" + content;
//准备用于发起请求的HttpWebRequest对象
WebRequest webRequest = WebRequest.Create(url);
HttpWebRequest httpRequest = webRequest as HttpWebRequest;
//准备用于用户验证的凭据
CredentialCache myCache = new CredentialCache();
myCache.Add(new Uri(url), "Basic", new NetworkCredential(username, password));
httpRequest.Credentials = myCache;
httpRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes(usernamePassword)));
//发起POST请求
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
System.Text.Encoding encoding = System.Text.Encoding.ASCII;
byte[] bytesToPost = encoding.GetBytes(data);
httpRequest.ContentLength = bytesToPost.Length; Stream requestStream = httpRequest.GetRequestStream();
requestStream.Write(bytesToPost, 0, bytesToPost.Length);
requestStream.Close();
string responseContent = "";
try
{
//获取服务端的响应内容
WebResponse wr = httpRequest.GetResponse();
Stream receiveStream = wr.GetResponseStream();
using (StreamReader reader = new StreamReader(receiveStream, System.Text.Encoding.UTF8))
{
responseContent = reader.ReadToEnd();
}
}
catch (Exception ex)
{
responseContent = ex.Message;
}
Response.Write(responseContent);
}
问题是,我用新浪的账号登陆时,先到新浪登陆,然后新浪跳到我的站点来,我怎么用
获取到的oauth_token oauth_token_secret 发送微博信息
问题是,我用新浪的账号登陆时,先到新浪登陆,然后新浪跳到我的站点来,我怎么用
获取到的oauth_token oauth_token_secret 发送微