转发与oauth c#

时间:2012-11-11 13:45:11

标签: c# api oauth twitter

我尝试使用twitter api to retweet a status,并使用以下代码发送帖子请求

  webRequest = WebRequest.Create("https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json") as HttpWebRequest;
               webRequest.ServicePoint.Expect100Continue = false;
               webRequest.Method = "POST";
               webRequest.ContentType = "application/x-www-form-urlencoded"; 


webRequest.Headers.Add("Authorization: OAuth oauth_consumer_key=\"xxxxx\", oauth_nonce=\"xxx\", oauth_signature=\"xxxx\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1352642106\", oauth_token=\"xxxx\", oauth_version=\"1.0\"");

  requestWriter = new StreamWriter(webRequest.GetRequestStream());
  requestWriter.Write(string.Empty);
  requestWriter.Close();

用户在上一步中使用我的推特应用程序进行了身份验证,但上面的代码什么也没做,甚至没有返回任何错误。

1 个答案:

答案 0 :(得分:2)

您需要致电webRequest.GetResponse()以实际发送请求。