The Facebook Developer Toolkit that I have been working on the past month or so was just released on the Visual Studio Express Website at http://msdn.microsoft.com/vstudio/express/showcase.... This toolkit should really help improve the programming experience of using the Facebook API using Microsoft tools (like C# and VB.net). Below is a summary of all the features available in the toolkit. The toolkit is completely open source and has all code available in both C# and VB.net
Facebook API Wrapper
The Facebook.dll is a wrapper to the Facebook API. In our opinion, this is a more complete wrapper than the client libraries available in other languages. In our wrapper, we have created strongly typed objects for all Facebook entities. This will greatly simplify the programming experience of anyone using the Wrapper. Developers accessing the API through the FacebookService component within our Facebook.dll will not need to understand the Facebook Authentication model or know how to work with the XML returned from the calls. All of this is abstracted from the developer, as shown below. (This sample assumes you already have an instance of FacebookService)
Visual C#
using System.Collections.Generic;
using System.Collections.ObjectModel;
...
Collection<User> friends = FacebookService1.GetFriends();
if(friends.Count > 0)
{
string firstFriendName = friends[0].Name;
}
VB.Net
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
…
Dim friends As Collection(Of User) = FacebookService1.GetFriends()
If friends.Count > 0 Then
dim firstFriendName as string = friends(0).Name
End If
Infinite Session Support
One other interesting feature of the Facebook API is infinite sessions. Infinite sessions is a concept that Facebook introduced to try to simplify the login process for third party applications. In this case, when a user logs in to an application they can specify that the application can use their credentials forever (without redirecting to the Facebook login page). In order to take advantage of this feature, an application needs a way to identify a user and associate them with their known Facebook Session identifier. If an application has knowledge of who the user is and tracked their session key from previous Usage. The application can set the UserId and SessionKey properties on the FacebookService component before making any api calls. If this is done and the session/user combination is valid, the application will avoid further login attempts.
Windows and Web Controls
Another feature that is included in the Facebook Developer Toolkit are controls for simplifying Web and Windows Development. These controls are installed in the Visual Studio Toolbar (in all editions of Visual Studio 2005) and allow the developer to simply drag the control from the toolbar to the form or webform. After the controls are added, the developer must just set the relevant control property with data retrieved using the FacebookService component described above. The controls themselves contain very simple User Interfaces but demonstrate how to build controls for these environments and good practices for leveraging the FacebookService data. The Controls that are available are:
- Friend List (Web and Windows)
- User Profile (Web and Windows)
- Photo Album (Web and Windows)
- Friend Map (Windows only)
- Event List (Windows only)
Windows Presentation Foundation
The Facebook Developer Toolkit also includes a sample application showing how the FacebookService can be leveraged from a Windows Application using Windows Presentation Foundation (WPF). The application is an animated rolodex, providing a visual display of a user's Facebook friends. This application was developed by my colleague, Kevin Marshall. It is a pretty cool sample and demo of some of the more compelling features of WPF. Unfortunately, currently devlopers can not access the contact information for Facebook user's, so the Rolodex can only display generic user data rather than more useful information like address, phone number or email address.
LINQ and Orcas
The last sample included in the Facebook Developer Toolkit is a sample application showing how the FacebookService can be leveraged from LINQ. This application is called Friend Finder. It shows how you can use LINQ on top of the data returned from the FacebookService to provide ordering, filtering and paging. This sample was coded by another colleague, Jerry Brunning and also shows a lot of the cool new langauage features available in Visual Studio codename "Orcas".
Documentation
The documetation included with the Facebook Developer Toolkit is pretty comprehensive. It contains Code Snippets, Class Definitions and a Quick Start Guide. You will have a link to the documentation in you Start Menu after installing and also it is available at c:\program files\coding4fun\facebook.
I hope everyone has fun trying out the toolkit, and let me know if you run into any problems.