tweetsharp: A .NET Twitter Library
I’ve been diving into the world of .NET development a little more these days and decided to further my leaning some by playing around with the Twitter API. In looking around the net I came across a cool Twitter library for .NET named tweetsharp. It appears to be a fairly new project, so the documentation is a bit lackluster at the moment. I put together a quick page that calls one of the tweetsharp methods to return a list of tweets from my friend’s timeline.
For those of you new to .NET, once you download the library and uncompress the files you will see two .DLL files. Copy these over to your Bin directory of your website. This will allow you to import this library and use it throughout your website or application. One file contains the base tweetsharp library and the other is a helper library for JSON. The data that is returned from the tweetsharp library can be returned in many formats, so if you plan on using the JSON data you will need to include the helper library.
Below is the code for the code behind page, which contains the guts of the logic. Notice the import calls to the tweetsharp files in the top half of the code. The rest of the code is fairly short. I call the tweetsharp library and set up my return data variables. I then bind the data to a ListView control.
<code lang="csharp[lines]">using System;<br></br>
public partial class test : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
var twitter = FluentTwitter.CreateRequest()
var response = twitter.Request();
var statuses = response.AsStatuses();
ListView1.DataSource = statuses;
The next part of the code is main ASPX file, and contains my ListView control that I have bound the data to. I set up my item template and then output my data.
Using the tweetsharp library makes this code super simple, as all the underlying API calls are taken care of by the library. I plan on updating this some more and I’ll provide some more examples.