Tuesday, May 18, 2010

Twitter API in C#

 

Today i have seen a thread in my favorite site Stackoverflow on Twitter. So i decided to create a small Twitter API WCF application.

Twitter is designed on REST architecture. Here is a sample code to integrate the Twitter in C#.

Download the TweetSharp

To Authenticate user in the Twitter:

ITwitterLeafNode twitter =FluentTwitter.CreateRequest()
.AuthenticateAs(StaticProperties.Username, StaticProperties.Password)
.Account().VerifyCredentials().AsJson();

if (twitter.Request().ResponseHttpStatusDescription == "OK")
{
}

To Update new Tweet:



ITwitterLeafNode twitter =FluentTwitter.CreateRequest()
.AuthenticateAs(StaticProperties.Username,StaticProperties.Password)
.Statuses().Update("Hello World).AsJson();
var request = twitter.Request();

Note: By using this API you will get all the Twitter related things,Like all Followers,To ReTweet etc.

0 comments:

 
Counter