In this post, we will get ourselves familiar with one of the popular Twitter API – Twitterizer & the famous Facebook SDK which was recently released by Microsoft. We will be using them in quite few of our up coming project will be doing in the near future. Go to these pages and make sure you download the packages and have the DLLs ready.
“Twitter”izer
This is very famous .Net library to enable easy communication with Twitter. The official Google Code page for this is - http://code.google.com/p/twitterizer/ and has got very good articles on how to get your started.
You can create a Console application or whatever to test the following out.
To use this library, you need to right on the project in VS and then say add reference and browse to the DLL you download from the Twitterizer page. Once you’ve done, you can use the following Using statement to enable use of this library in the code.
using Twitterizer.Framework;
Then you need to create an instance of Twitter, passing the username and password as the two parameters.
Twitter t = new Twitter(twitUsername, twitPassword);
Now to get the time line for this user, use the following line.
TwitterStatusCollection timeline = t.Status.UserTimeline();
Now that you’ve got a list, you can merrily iterate through this to get each of the status updates and the details pertaining to each one of them. I’ve used only the status text and the date, you can get more like ID, user id, etc… Just refer the documentation and you should be able to see more.
foreach (TwitterStatus status in timeline)
{
textBox3.Text += (status.Text + " " + status.Created.ToLongDateString() + "\n\n");
}
You can set the status of the current user using
t.Status.Update(“http://geekswithblogs.net/maxonweb”);
This would be sufficient for us to help us look into the WPF application. In our Silverlight and ASP.NET MVC application we’ll use the Twitterizer library more.
Facebook SDK
First of all to use the Facebook SDK, you would need a API Key from Facebook, this is fairly very simple, the step are given very clearly in the facebook developer wiki site here.

You can download help documentation from here. This page also has some cool video to help you get started. Some WPF related help is available here. Just go though all of them and get yourself familiar with the Facebook SDK.
Similar to what we did for Twitterizer, add reference to Facebook.dll and Facebook.Winforms.dll. Then, use the following using statements atop the code behind file.
using Facebook;
using Facebook.Schema;
using Facebook.Session;
using Facebook.Winforms.Components;
using Facebook.Rest;
using Facebook.BindingHelper;
Just instantiate DesktopSession and API of Facebook.
DesktopSession session;
Api api;
Once you have them in place, have your API key in a string variable, like
string api_key = "sdfgsdfgsdfgsdfg1d32d26fe2361d5fc723";
Then to create a session, for us to interact with Facebook,
session = new DesktopSession(api_key, null, null, true, new List<Enums.ExtendedPermissions>()
{
Enums.ExtendedPermissions.read_stream, Enums.ExtendedPermissions.publish_stream
});
session.Login();
api = new Api(session);
When you run the application, the bit of code above is responsible for popping a small windows which asks you to login to your facebook account and asks for your permission to allow access the application to your account.
Once you login, it will ask you to allow access and etc… approve them all.
Now to get your latest facebook status, use the following statement
string status = api.Status.Get().First().message;
Now to set your status, use this one
api.Status.Set("Testing 1, 2, 3.....");
But pretty much what we’ve covered here should be enough for our WPF application that we will be developing in the next few weeks.
Please put your questions as feedback to this post.