One major reason for the great success of the micro-blogging web site Twitter is that it does just one job and does that job very well: users of Twitter can post short messages of up to 140 characters at a time and Twitter displays those messages.
It is used both by users telling the world what they are doing but it is also increasingly being used by companies (such as Dell) to communicate with their users. A task that’s made even easier by the fact that Twitter has its own API (Application Programming Interface) with which programmers can develop applications that update Twitter directly. Therefore, the C# programmer does not need to use the Twitter web site to talk to their users; they just need the Twitter API.
Using the Twitter API with C#
The key for any C# programmer who is going to use the Twitter API is not an in depth knowledge of the API itself. Instead it is just a matter of installing the appropriate library. The current Twitter approved libraries (for both C# and other programming languages) are available from the Twitter libraries web page. Once installed then the libraries can be used directly in any C# application.
Installing a Twitter Library for C#
One of the libraries that is very easy to install and to use is theTwitterizer .NET Twitter Interface. The installation process is simple:
- Download the Twitterizer library zip file
- Extract the Twitterizer API dll file
- Add the Twitterizer library as a reference in the C# IDE (Integrated Development Environment) being used
The library will now be ready for use by C#.
Using a Twitter Library with C#
Once the library has been added in as a reference within an IDE then it can be included in a project:
And then the Twitterizer functionality can be used within a C# class. Initially Twitter will need to be initialized (for which the username and password will be required):
And then an update can be sent to Twitter:
If the Twitter web site is now examined then it will have been updated and will show an entry something like:
The next stage is for the programmer to inform Twitter that the update is actually coming from their own application.
C# and the Message Source
By default the message source will be ‘Twitterizer’ when using the Twitterizer library. However that can be changed to the programmer’s own application, but before that can be done Twitter must be made aware of the application.
A new application must be registered with Twitter before it can be used as a valid source. That must be done on the Twitter web site. Once the application has been registered (and accepted) as a source then the application can be used when initializing Twitterizer’s Twitter class:
The micro-blog will now be shown to originate from the programmer’s application instead of Twitterizer.
Summary
A C# application can easily send updates to Twitter by making use of the Twitter API. However this task is made even easier for the programmer due to the existence of a number of C# Twitter libraries such as Twitterizer.
Once the appropriate library is installed then the C# programmer can send updates to Twitter and can even register their own application as a valid source for Twitter.