HowTo: Tweet with C#

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.

kick it on DotNetKicks.com

3 Comments so far »

  1. Dew Drop - April 23, 2009 | Alvin Ashcraft's Morning Dew said

    am April 23 2009 @ 2:48 pm

    [...] HowTo: Tweet with C# (Robert Muehsig) [...]

  2. Luc said

    am April 24 2009 @ 4:58 pm

    Have you heard of messagepub? We provide an API to let you easily send messages on Twitter, SMS, Email, Phone, AIM, and Google Chat. We just released a C# library so if you are a C# developer, you can start sending multi-channel messages using a single API.

    In the following blog post, there is a demo showing how to use C# to interact with our API:
    http://blog.messagepub.com/2009/04/24/new-c-helper-library/

  3. Interesting Finds: 2009 04.23~04.30 - gOODiDEA.NET said

    am April 30 2009 @ 4:35 am

    [...] HowTo: Tweet with C# [...]

Comment RSS · TrackBack URI

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: