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:
@using Skybrud.Social.Twitter.Models.Statuses
@using Skybrud.Social.Twitter.Responses.Statuses
@inherits WebViewPage<Skybrud.Social.Twitter.TwitterService>
@{
// Make the call to the API
TwitterPostStatusMessageResponse response = Model.Statuses.PostStatusMessage("This is a test");
// Get a reference to the tweet (from the response body)
TwitterStatusMessage tweet = response.Body;
// Write out some information about the tweet
<pre>@tweet.Id</pre>
<pre>@tweet.Text</pre>
<pre>@tweet.User.ScreenName</pre>
<pre>@tweet.RetweetCount</pre>
}
If the tweet is successfully posted to the API, the method will return an instance of the TwitterPostStatusMessageResponse
class (as shown in above).