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

  • image1528-570x194_thumb.png
    Introduction to Redis on Windows & Redis usage with .NET

      Redis belongs to the NoSQL data banks and you will find it in the group of Key-Value Stores. Redis is often named “Blazing Fast” and according to the Stackoverflow Thread it is used to be two time (while writing) and three times (while reading) quicker than MongoDB. Even if the comparison is a little ...

  • Automated Security Analyser for ASP.NET websites

    Evil Hackers are lurking everywhere and many Web-applications are delicately and share “too much” with the attacker. A quick (first!) overview offers the Tool “ASafaWeb”. All the website does is making a few requests and writing an Analyses including problem solving’s. There are no permanent disadvantages (bad requests/ DoS attacks and so on). Example: KnowYourStack.com ...

  • image1489-570x194.png
    „Sign in with Twitter“ for your own ASP.NET WebApp

      “Sign in with Twitter” is a popular practice to authenticate the users on your website. One advantage compared to an own registration is the lower inhibition for the user. But on the other hand Twitter doesn’t fess up with all the information’s and you will get into a kind of addiction. At the end ...

  • image1485-570x194_thumb.png
    CodePlex is going to be updated

      CodePlex the Microsoft Open Source Project Hosting Plattform hasn’t changed that much in the last few years and for a few times I thought Microsoft stopped the whole developing process. But now I found out that there is still life in the project. Maybe it is because of the success of GitHub or because ...

  • image1474_thumb.png
    What does Adobe in the flash-free web? Magazine-Style Layouts with CSS Regions!

      Adobe is well known for Photoshop and Flash but of course there is a lot more. According to the “Future Post” from Google Adobe declared one of their big subjects on a Blogpost. I’m talking about the W3C Working Draft to CSS Regions. Adobe cooperates with the WebKit Team and W3C on this. What ...

Support us