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.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

About the author

Written by Code Inside Team

Currently there is no additional info about this author.

6 Responses

  1. 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/

    Reply
  2. Hi

    I’m a newbie in developing twitter. how can i use my website act like a user in twiiter and allow other user follow me then the RSS on my website can automatically send the tweet updates to my followers. I really need help Thanks a lot.

    Reply
  3. This does not work anymore. can you update ?

    Reply
  4. TweetSharp is no more active..
    Please refer twitter’s documentation for development..

    Reply

Comment on this post

Recent Posts

  • WebDev Playground: dabblet.com for HTML/CSS, jsfiddler.com for JS & HUrl.it for REST

      What was reserved for mighty Desktop Apps in the past is now coming closer to the web. I’ve going to present three tools to you which are very useful for web developer. At least all the tools are quite cool in there functionality. Playground for HTML/CSS If you need a quick Playground for CSS ...

  • image1452_thumb.png
    Javascript to Dart Translator

      Dart, a Google Javascript alternative was presented a few months ago and the web developer scene are a little bit unsure about the usability of Dart. To declare the language Google has translated the Javascript basics into Dart. The result is this “Translator”. In my opinion the name doesn’t find that well because it’s ...

  • image1366-570x194.png
    Twitter Bootstrap as UI-kit

      HTML and CSS are not foreign words for me but I regret, I’m not a Web designer – I see myself as a webdeveloper. But at least a dressy side is a must. But thank good there are some ready “Systems”. Twitter Bootstrap Twitter Bootstrap is a Toolkit for every kind of Web applications. ...

  • image1441.png
    Fix: the value ‚x‘ is not valid for Foo in ASP.NET MVC

      To get files into the MVC Controller Modelbinding from MVC is a clever method. But in fact it is a little bit complicated to set the error message if the connection failed. Example: public class RegisterModel { ... [Required] [DataType(DataType.EmailAddress)] [Display(Name = "Email address")] public string Email { get; set; } [Required] [Display(Name = ...

  • You Tube API – recall Video Meta files with .NET

      A loooong time ago I’ve blogged about how to access to You Tube with the Google Data APIs. After all that time there are several new ways how to recall files. Google offers You Tube a “simple” surface. If you prefer to do low-Level HTTP calls it is also possible. Aim: I want the ...

Support us