23 April 2009 HowTo, Tweetsharp, Twitter Robert Muehsig

imageTwitter is the internet Microblogging Service - this is my acc BTW. Twitter has an API since the beginning (and IMHO is this one big reason why twitter is so successful). The Twitter API is REST based and so you can easily create Twitter-Clients with .NET. If you don´t want to create the HTTP basic stuff, check out existing libraries, like Tweetsharp.

Twitter API
You can find the Twitter API docs here and a good overview here.

Twittern via C# - "low level"
You can use HttpRequest & HttpResponse objects to use twitter: Sample here.

C# APIs for Twitter
If you don´t want do deal with the low level things, then you should look at these C# APIs

One example: Tweetsharp
Tweetsharp is a really cool, fluent interface for accessing Twitter, Url-Shorting-Services, Twitpic and so on. Here I create a simple update on twitter:

    class Program
    {
        static void Main(string[] args)
        {
            var twitter = FluentTwitter.CreateRequest()
            .AuthenticateAs("USERNAME", "PASSWORD")
            .Statuses().Update("testing, one, two, three!")
            .AsJson();

            var response = twitter.Request();
        }
    }

Look at the Google Code wiki or on the homepage for more information.

Authorization
If you use a 3rd Party Twitter Client (like Tweetdeck) you have to type in your credentials to get access to your Twitter-Data. This is from a security point of view not very smart. That´s why Twitter enabled OAuth authorization, which is also provided by Tweetsharp (look here & here).

Sample
You can find a nice WPF Twitter Client on Codeplex.


Written by Robert Muehsig

Software Developer - from Dresden, Germany, now living & working in Switzerland. Microsoft MVP & Web Geek.
Other Projects: KnowYourStack.com | ExpensiveMeeting | EinKofferVollerReisen.de

If you like the content and want to support me you could buy me a beer or a coffee via Litecoin or Bitcoin - thanks for reading!