Skip to content
linvi edited this page May 8, 2015 · 25 revisions

Before you start - Important

Please verify that the time of your machine is correctly setup (both the time and the region).

Twitter verifies the DateTime issued when performing a request. If the DateTime is not the same as their servers, all WebRequests to the API will result in a 401 status code (UnAuthorized). When a 401 exception is received, Tweetinvi will either throw the Exception or return null to all your operations.

Let's get it started!

Configure your credentials

Now that we have properly configured our environment we can start using Twitter. Twitter execute queries against credentials that are stored as OAuth Tokens. These tokens allow Twitter to identify the Application that want to execute an operation on behalf of a specific User.

Because Twitter requires these credentials for each of the query executed, the first thing we need to do is to set the credentials.

The credentials contains 2 keys for the User also called Access Token, and 2 keys for the Application also called Consumer Token.

// Set up your credentials
TwitterCredentials.SetCredentials("Access_Token", "Access_Secret", "Consumer_Key", "Consumer_Secret");

When the credentials have been set, all operation performed with Tweetinvi will use these credentials.

Click Learn more about credentials

Let's code with statics!

Now that our credentials have been configured we are ready to use all the Twitter features!

The Tweetinvi namespace (using Tweetinvi;) contains a bunch of static classes that will let the developers perform all the operation they can dream of.

Here are few examples:

// Publish a tweet
Tweet.PublishTweet("@TweetinviApi rocks!");

// Get the details of the Logged User
var loggedUser = User.GetLoggedUser();

// Get my Home Timeline
var tweets = Timeline.GetHomeTimeline();

In this documentation you will be able to learn more about the different static classes that exist.

Here is a list of the static classes you are most likely to use:

  • Tweet, User, Timeline, Message, Search, Stream, TwitterCredentials, CredentialsCreator, ExceptionHandler, TweetinviConfig, Sync.

Here are other static classes that you might like:

  • Account, Friendship, Trends, TweetList, SavedSearch, Geo, Help.

Here are static classes for advanced users:

  • RateLimit, TwitterAccessor, TweetinviEvents, TweetinviContainer

Let's code with objects!

Static classes allow developers to get objects and information back from Twitter. Each type of object contain a set of methods that you will be able to use in order to update them or get additional information.

The best example is the LoggedUser class, which gives access to a whole set of operations that can be performed on the account.

// Get the LoggedUser from the static class User
var loggedUser = User.GetLoggedUser();

// Get the AccountSettings from the loggedUser object
loggedUser.GetAccountSettings();
Clone this wiki locally