How to update Twitter status from C #?

I want to update the status on Twitter without using external libraries or dll-s. I found, for example, this solution:

http://www.dreamincode.net/code/snippet2556.htm

But this does not work and does not give any error.

Could you tell me how to programmatically update the status from C #?

When I catch the error, I get:

500 Internal Server Error

+1
source share
6 answers

This may not give any errors, because the catch block is an “exception” exception. Try getting rid of try / catch (for testing purposes only) or doing something in catch to notify you of any errors.

+4
source

WCF API Twitter CodePlex, Vertigo

, WCF REST Starter Kit ,

, , Starter Kit

public void PostTweet(string username, string password, string tweet)
{
  using (var client = new HttpClient())
  {
      System.Net.ServicePointManager.Expect100Continue = false;

      client.TransportSettings.Credentials =
          new NetworkCredential(username, password);

      var form = new HttpUrlEncodedForm();
      form.Add("status", tweet);

      client.Post("http://twitter.com/statuses/update.xml", form.CreateHttpContent())
          .EnsureStatusIsSuccessful();
  }
}
+1

Yedda Twitter, , , . , HTTP-/ - XML, /.

0

Dream-in-Code,

http://www.dreamincode.net/code/snippet2556.htm

-, Stream , ,

//

( post = request.GetRequestStream()) {     post.Write(byteData, 0, byteData.Length); }

-, , :

string tweet

Twitter , 140 , , 140 . , .

0

, twitter #... Microsoft.Http, .

http://msdn.microsoft.com/en-us/netframework/cc950529.aspx

Watch the video and enter =)

http://channel9.msdn.com/shows/Endpoint/endpointtv-Screencast-Consuming-REST-services-with-HttpClient/

Happy coding

0
source

All Articles