Twitter Posting a tweet

Posting a tweet

In the statuses endpoint, the PostStatusMessage method lets you post a tweet on behalf of the authenticated user. The method has a couple of overloads, and in it's most simple form, you can post a new tweet like this:

// Make the call to the API
TwitterStatusMessageResponse response = service.Statuses.PostStatusMessage("This is a test");

// Write out some information about the tweet
Console.WriteLine(response.Body.Text);
Console.WriteLine(response.Body.User.ScreenName);

If the tweet is successfully posted, the method will return an instance of the TwitterStatusMessageResponse class.

Replying to a tweet

The example above will just create a new tweet. In order to reply to another tweet, you should specify the ID of that tweet - eg. like:

// Make the call to the API
TwitterStatusMessageResponse response = service.Statuses.PostStatusMessage("This is a test", 610040220470349824);

Options

Another overload of the PostStatusMessage method allows you to specify some further options. By specifying an instance of the TwitterPostStatusMessageOptions class, the example above is similar to calling:

// Make the call to the API
TwitterStatusMessageResponse response = service.Statuses.PostStatusMessage(new TwitterPostStatusMessageOptions {
    Status = "This is a test",
    ReplyTo = 610040220470349824
});

To tag the tweet with a specific location, you can fill out a few extra properties like:

// Make the call to the API
TwitterStatusMessageResponse response = service.Statuses.PostStatusMessage(new TwitterPostStatusMessageOptions {
    Status = "This is a test",
    ReplyTo = 610040220470349824,
    Latitude = 55.861912,
    Longitude = 9.839534
});