If you
are developing a Winform application you should add the
FacebookService
component to your toolbox in Visual Studio. To do this, right-click in
the area
of the toolbox where you want the controls to go, and select “Choose
Items”
from the pop-up menu.

To start
utilizing the Facebook API, you will need to add the FacebookService
component
to your project. To do this just drag an instance of
FacebookService from
the toolbox onto the component tray and enter your API Key.

The FacebookService component contains methods that wrap all of the
methods of
the Facebook API. The following provides an example for getting
all the
friends of the logged in user. This method returns a generic
collection
of user objects. The user object is a strongly typed
representation of a
Facebook User profile.
In order
to leverage the facebook platform from a winform application you first
need to
establish a facebook session on behalf of the user of your
application.
The first time a user is using your application, this will require
showing them
a facebook login page and then getting back a new secret key that is
specific
to their session and also the session key associated with the facebook
session
that they just initiated. The Toolkit provides a easy wrapper
method that
allows you to do this. Allow you have to do is call
ConnectToFacebook on
the instance of FacebookService that you created by dragging it onto
your
form. After you have a valid session you can access the various
elements
of data using accessor properties on your FacebookService
instance. When calling ConnectToFacebook you can optionally pass
in a set of Required Permissions that the user should be prompted for
when logging in to your application.
Now that
we have a valid session, we can use the FacebookService to make rest
api
calls. For more information on the rest api, go to http://wiki.developers.facebook.com/index.php/API.
The following provides an example for getting all the friends of the
logged in
user. This method returns a generic collection of user
objects. The
user object is a strongly typed representation of a Facebook User
profile.
Visual C#
using
System.Collections.Generic;
using
System.Collections.ObjectModel;
using
facebook.Schema;
…
IList<user>
friends = facebookService1.friends.getUserObjects();
Visual Basic
Imports
System.Collections.Generic
Imports
System.Collections.ObjectModel
Imports
facebook.Schema
…
Dim friends As IList(Of
user) =
facebookService1.friends.getUserObjects()
If you
have just simple needs and want to display some typical facebook
information,
we have provided some user controls.
The following walks through the basic steps you would need to do to use
leverage one of these controls
1. Drag a FriendList from the
toolbox
onto the design surface for the form

2. Find Load in the Event list in
the
property window, type Form_Load. Press Enter.

3. In the generated Form_Load
method, set
the Friends property of the FriendList control to the Collection
returned by
calling the GetFriends method of the FacebookService. As shown
here:
Visual
C#
private
void Form_Load(object
sender, EventArgs e)
{
friendList1.Friends = facebookService1.friends.getUserObjects();
}
Visual Basic
Private
Overloads Sub
OnLoad()
friendList1.Friends =
FacebookService1.friends.getUserObjects()
End Sub
Facebook Developer Toolkit: http://facebooktoolkit.codeplex.com
Facebook Developer WIKI
Page: http://wiki.developers.facebook.com/index.php/Main_Page
Facebook Developer wiki, the official documentation for the Facebook Platform.
Extended Permissions
Documentation: http://wiki.developers.facebook.com/index.php/Extended_permissions
Official documentation for
extended permissions.