Professional Documents
Culture Documents
Developer Toolkit
Developed for Microsoft By Clarity Consulting Inc. -
www.claritycon.com
Table Of Contents
Leveraging the Facebook API in 5 minutes.................................................................4
Desktop Development............................................................................. ................4
Web Development............................................................................... ....................7
Pre-requisites................................................................................................... .........12
Introduction...................................................................................... ........................12
Overview.................................................................................. ................................13
Facebook API Overview......................................................................................... .13
Using the FacebookService to Access the API........................................................13
Infinite Sessions.................................................................................................13
Facebook Desktop Development...........................................................................13
Facebook Web Development.................................................................................14
Using LINQ................................................................................................... ..........15
Detailed Class Design ................................................................................ ..............16
Facebook.Components..........................................................................................16
FacebookService Class.......................................................................................16
Facebook Data Objects..........................................................................................32
Album Class..................................................................................................... ...32
Photo Class.................................................................................................. .......34
FacebookEvent Class..........................................................................................35
Group Class................................................................................... .....................38
GroupUser Class.................................................................................. ...............40
User Class..........................................................................................................41
SchoolHistory Class............................................................................................45
HighSchool Class............................................................................... .................45
HigherEducation Class...................................................................................... ..46
Network Class................................................................................................... .46
Location Class...................................................................................................47
Work Class.................................................................................................. .......48
Code Snippets.......................................................................................................... .49
Windows Form: Application Setup.........................................................................49
Windows Form: Retrieving Friends.........................................................................49
Windows Form: Utilizing the FriendList Control......................................................49
Windows Form: Hooking a FriendList Control to a Profile Control..........................50
Web Application: Authentication Process...............................................................51
Leveraging the Facebook API in 5 minutes
Desktop Development
• Satisfy Pre-requisites described below
o Windows Application
Visual C#
Visual Basic
• Add the FacebookService component from the toolbox to the Form’s
component tray
o Find Load in the Event list in the property window, type Form_Load.
Press Enter.
Visual C#
private void Form_Load(object sender, EventArgs e)
{
friendList1.Friends = FacebookService1.GetFriends();
}
Visual Basic
friendList1.Friends = FacebookService1.GetFriends()
End Sub
• Press F5 to run the application
Web Development
• Satisfy Pre-requisites described below
Visual C#
Visual Basic
• Switch to Design View of Default.aspx
• On Default.aspx, drag a friendlist from the toolbox
Visual C#
public partial class _Default : Page
{
Facebook.Components.FacebookService _fbService = new
Facebook.Components.FacebookService();
Visual Basic
Public Partial Class _Default
Inherits Page
Private _fbService As Facebook.Components.FacebookService = New
Facebook.Components.FacebookService()
' ApplicationKey and Secret are acquired when you sign up for
_fbService.ApplicationKey = "YOURKEYHERE"
_fbService.Secret = "YOURSECRETHERE"
• Set the IsDesktopApplication property of the FacebookService component
Visual C#
_fbService.IsDesktopApplication = false;
Visual Basic
_fbService.IsDesktopApplication = False
Visual C#
// When the user uses the Facebook login page, the redirect back here
will will have the auth_token in the query params
string authToken = Request.QueryString["auth_token"];
Visual Basic
Dim sessionKey As String =
TryCast(Session("Facebook_session_key"), String)
Dim userId As String = TryCast(Session("Facebook_userId"), String)
' When the user uses the Facebook login page, the redirect back
here will will have the auth_token in the query params
Dim authToken As String = Request.QueryString("auth_token")
Visual C#
if (!String.IsNullOrEmpty(sessionKey))
{
_fbService.SessionKey = sessionKey;
_fbService.UserId = userId;
}
Visual Basic
Visual C#
else if (!String.IsNullOrEmpty(authToken))
{
_fbService.CreateSession(authToken);
Session["Facebook_session_key"] = _fbService.SessionKey;
Session["Facebook_userId"] = _fbService.UserId;
Session["Facebook_session_expires"] = _fbService.SessionExpires;
}
Visual Basic
' This will be executed when Facebook login redirects to our page
ElseIf (Not String.IsNullOrEmpty(authToken)) Then
_fbService.CreateSession(authToken)
Session("Facebook_session_key") = _fbService.SessionKey
Session("Facebook_userId") = _fbService.UserId
Session("Facebook_session_expires") =
_fbService.SessionExpires
• If neither, we need to redirect the user to the Facebook hosted login page
Visual C#
else
{
Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" +
_fbService.ApplicationKey + @"&v=1.0");
}
Visual Basic
Else
Response.Redirect("http://www.Facebook.com/login.php?api_key=" &
_fbService.ApplicationKey & "&v=1.0")
End If
Visual C#
if (!IsPostBack)
{
// Use the FacebookService Component to populate Friends
MyFriendList.Friends = _fbService.GetFriends();
}
Visual Basic
If (Not IsPostBack) Then
' Use the FacebookService Component to populate Friends
MyFriendList.Friends = _fbService.GetFriends()
End If
Pre-requisites
First, you download one of the Visual Studio Express products . To develop a
desktop application, you can use Visual C# 2005 Express Edition (or later) or Visual
Basic 2005 Express Edition (or later). If you want to build a web application, you
can use Visual Web Developer 2005 Express Edition (or later).
Next, in order to use the Facebook API, you must first register for a developer
account with Facebook at http://developers.Facebook.com/account.php. You will
need to specify whether your application is a Website or a Desktop application.
After registering for your developer account, you will receive and API key and secret.
These are critical for using the Facebook API and you should keep this readily
available
Introduction
This document outlines the components and controls that are available for to help
simplify development against the Facebook API. The main component is the
FacebookService component. The FacebookService wraps the Facebook API and
provides an easy to use interface for calling the different methods currently
available in the 1.0 version of the Facebook API. In addition, some Windows and
web controls were installed which will provide a quick way to start leveraging the
Facebook data in your application. We’ve also provided you with some cool fun
samples. These can be found in <INSERT DIRECTORY HERE>. Additionally, we’ve
provide all the source code for the API, components, controls and samples for you to
explore.
Overview
All of the sections below assume that the developer has signed up for a Facebook
developer account and received an API key and secret from Facebook.
For more information on the available functions, see the API documentation at
http://developers.Facebook.com/documentation.php?v=1.0
Infinite Sessions
The Facebook API supports Infinite Sessions. What this means is that users of
custom developed Facebook desktop applications have the ability to save their
credentials and not be required to login to the application on subsequent uses.
In order for an application to take advantage of infinite sessions, the application
should check SessionExpires property of the Facebook Service after a Session is
initiated. If this property is false, the application can store the userId and
SessionKey that are associated with the user and set them on the
FacebookService whenever this user returns.
Visual C#
using System.Collections.Generic;
using System.Collections.ObjectModel;
…
Collection<User> friends = FacebookService1.GetFriends();
Visual Basic
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
…
Dim friends As Collection(Of User) = FacebookService1.GetFriends()
c. Store the user’s session information for making calls to the Facebook
service.
Using LINQ
The toolkit contains some sample code showing (both a web application and
Windows application version) how LINQ and Orcas can be used to provide a richer
set of development features against the Facebook API data. The samples included
will only work in “Orcas” (the codename for the next version of Visual Studio) and
show how we can right code using a syntax similar to SQL to filter and search
through the friends that are returned from Facebook. The samples leverage LINQ
over XML and run the filtering directly against the returned XML. Alternatively, the
LINQ code could just as easily have been written against the Generic Collections
returned by the our toolkit. For more information on LINQ, check out
http://msdn2.microsoft.com/en-us/netframework/aa904594.aspx. If you want to
download Orcas and try out LINQ and the enclosed samples, you can do so here,
http://msdn.microsoft.com/vstudio/express/future.
1.1.1.1Property: ApplicationKey
This property is required to be set by all consuming applications. This
property should be set to the API key acquired from Facebook when
developer signed up for a Facebook developer account.
1.1.1.3Property: Secret
This property is required to be set by all consuming applications. This is
the secret used to encrypt parameters passed to the Facebook API. For
web applications, the secret is constant and set at the beginning of
interaction with the service. For Windows applications, an initial secret
is required to establish a session, but a new secret is acquired that
coincides with each session.
1.1.1.4Property: SessionExpires
This property is an indicator of whether the current session is an infinite
session or not. The value is determined after a user of the consuming
application logs in on the Facebook hosted web page. Consuming
applications can leverage an infinite session by storing the session
information locally and by passing the logon process in subsequent
interactions with the user.
1.1.1.5Property: SessionKey
This property stores the session key for the current user session. This
can either be set by the consuming application (which would typically be
done when the consuming application recognizes a user that has an
infinite session established) or will be set by the FacebookService after
the logon process is complete
1.1.1.6Property: UserId
This property is stored the Facebook userid. Similar to the SessionKey,
in the case of infinite sessions the comsuming application will set this
property with the known UserId, otherwise this property will be set by
the logon process.
Parameters:
Parameter Description
The Facebook identifier of the pending photo to be
photoId
tagged
The message that should be associated with the tag. Use
tagText
this OR tag User Id. Not both.
tagUserId The Facebook userid of the person the tag points to
The X coord (in pixels) where the tag should begin in the
xCoord
specified picture
The Y coord (in pixels) where the tag should begin in the
yCoord
specified picture
Exceptions:
1.1.1.8Method: AreFriends
This method wraps the Facebook API method friends.areFriends. This
method is used to determine if two Facebook users are friends or not.
Definition (1): public bool AreFriends(string userId1, string userId2)
Parameters (1):
Parameter Description
userId1 The Facebook identifier of the first user
userId2 The Facebook identifier of the second user
Parameters (2):
Parameter Description
The a strongly typed instance of a User representing the
user1
first Facebook user
The a strongly typed instance of a User representing the
user2
second Facebook user
Exceptions:
1.1.1.9Method: ConnectToFacebook
This method is not typically used by the consuming application. The
FacebookService will check if there is a valid session that it can use to
make API calls, if not it will invoke the ConnectToFacebook method. This
method is only needed by desktop applications and uses a hosted web
browser to allow the user to login to the Facebook hosted login page.
Parameters:
Parameter Description
None None
Exceptions:
1.1.1.10Method: CreateSession
This method has a public version and a private version. The private
version is used for Windows applications and is called from
ConnectToFacebook. The public version takes in an auth token and is
used by web based applications. Web based applications get the auth
token as a url parameter after the user logins on the Facebook hosted
webpage. The web application then needs to start the session using this
method and passing in the auth token.
Parameters (1):
Parameter Description
none None
Parameters (2):
Parameter Description
The authentication token returned to the web application
authToken
from the Facebook login page.
Exceptions:
1.1.1.11Method: GetEventMembers
This method wraps the Facebook API method events.getMembers. This
method is used to return all the users that have been invited to an event
and their current rsvp status.
Parameters:
Parameter Description
eventId The Facebook identifier of the event
Exceptions:
FacebookException: This base class of all exceptions. If
exception could not be classified, FacebookException will be
used.
FacebookInvalidUserException: The user that the call was made
on behalf of is not valid.
FacebookRequestLimitException: Indicates that the consuming
application has made too many Facebook API calls in short
period of time.
FacebookServiceUnavailableException: Indicates that the
website used to host the Facebook REST client was not available.
FacebookSigningException: Indicates that the secret or API key
were not specified or were invalid.
FacebookTimeoutException: Indicates that the Facebook API did
not respond in a within the timeout threshold
1.1.1.12Method: GetEvents
This method wraps the Facebook API method events.get. This method is
used to retrieve event information. There are overrides supporting get
by event id, user id and date.
Parameters (1):
Parameter Description
None Get Events that the logged in user is invited to
Parameters (2):
Parameter Description
The Facebook userId that events are retrieved for. Will
userId
return all events this person is invited to.
Parameters (3):
Parameter Description
A collection of eventIds. Will return the event information
eventList
for each event matching an event id passed in.
Parameters (4):
Parameter Description
The Facebook userId that events are retrieved for. Will
userId return events this person is invited to that are also
specified in the eventList.
A collection of eventIds. Will return the event information
eventList for each event matching an event id passed in that has
the specified UserId invited.
Parameters (5):
Parameter Description
The Facebook userId that events are retrieved for. Will
userId return events this person is invited to that are also
specified in the eventList.
A collection of eventIds. Will return the event information
eventList for each event matching an event id passed in that has
the specified UserId invited.
Only retrieve events matching the above criteria and
startDate
starting after this date.
Only retrieve events matching the above criteria and
endDate
ending before this date.
Exceptions:
Parameters:
Parameter Description
none Get friends of the logged in user
Exceptions:
1.1.1.14Method: GetFriendsAppUsers
This method wraps the Facebook API method friends.getAppUsers. This
method is used to get all the friends of the logged in user that are also
users of this consuming application.
Parameters:
Parameter Description
Get friends of the logged in user that are users of this
none
application
Return Type: Collection<User>: A collection of populated user objects
representing each of the logged in user’s friends that are
also users of this application.
Exceptions:
1.1.1.15Method: GetGroupMembers
This method wraps the Facebook API method groups.getMembers. This
method is to retrieve profile information about all Facebook users that
are members of a particular group.
Parameters:
Parameter Description
groupId The Facebook identifier of the group
Exceptions:
1.1.1.16Method: GetGroups
This method wraps the Facebook API method groups.get. This method is
used to retrieve the groups matching a specific criteria.
Parameters (1):
Parameter Description
None Get all groups for the logged in user
Parameters (2):
Parameter Description
userId The Facebook userId to return groups for
Parameters (3):
Parameter Description
A collection of group ids. Return all groups matching a
groupList
group id in the list.
Parameters (4):
Parameter Description
userId The Facebook userId to return groups for
A collection of group ids. Return all groups matching a
groupList
group id in the list.
Return Type: Collection<Group>
Exceptions:
1.1.1.17Method: GetPhotoAlbums
This method wraps the Facebook API method photos.getAlbums. This
method is used to get photo album details based on search criteria
Parameters (1):
Parameter Description
None Get all albums for the logged in user
Parameters (2):
Parameter Description
userId Facebook userid to retrieve all albums for
Parameters (3):
Parameter Description
albumList Collection of Facebook album ids to retrieve
Parameters (4):
Parameter Description
userId Facebook userid to retrieve albums for
albumList Collection of Facebook album ids to retrieve
Exceptions:
1.1.1.18Method: GetPhotos
This method wraps the Facebook API method photos.get. This method is
used to get photos based on search criteria.
Parameters (1):
Parameter Description
The Facebook identifier of the album to retrieve photos
albumId
for
Parameters (2):
Parameter Description
Collection of Facebook photo identifier to return
photoList
information about
Parameters (3):
Parameter Description
The Facebook identifier of the album to retrieve photos
albumId
for
Collection of Facebook photo identifier to return
photoList
information about
Exceptions:
1.1.1.19Method: GetTags
This method wraps the Facebook API method photos.getTags. This
method is used to retrieve all tags for a particular photo.
Parameters:
Parameter Description
photoList Collection of Facebook photo identifiers to return tags for
Exceptions:
FacebookException: This base class of all exceptions. If
exception could not be classified, FacebookException will be
used.
FacebookInvalidUserException: The user that the call was made
on behalf of is not valid.
FacebookRequestLimitException: Indicates that the consuming
application has made too many Facebook API calls in short
period of time.
FacebookServiceUnavailableException: Indicates that the
website used to host the Facebook REST client was not available.
FacebookSigningException: Indicates that the secret or API key
were not specified or were invalid.
FacebookTimeoutException: Indicates that the Facebook API did
not respond in a within the timeout threshold
1.1.1.20Method: GetUserInfo
This method wraps the Facebook API method users.getInfo. This method
is used to retrieve profile information for a set of users.
Parameters(1):
Parameter Description
none Get the user profile for the logged in user
Parameters(2):
Parameter Description
userIds Comma separated list of Facebook user identifiers
Return Type: User
Exceptions:
1.1.1.21Method: UploadPhoto
This method wraps the Facebook API method photos.upload. This
method is used to upload a new photo. The uploaded photo will be
considered pending until the user utilizes the website to confirm the
photo.
Parameters:
Parameter Description
The album identifier to upload the photo to. If null, then
albumId
will upload to default album
uploadFile File containing the photo to upload.
Exceptions:
1.1.1.23Property: CoverPhotoId
The Facebook identifier of photo that is used as the cover photo for the
album
1.1.1.24Property: CreateDate
The date that the album was created
1.1.1.25Property: Description
The user entered description of the album
1.1.1.26Property: Location
The location that the album pertains to
1.1.1.28Property: Name
The name of the album
1.1.1.29Property: OwnerUserId
The Facebook user id of the person who created the album
Photo Class
This class contains the information about a Facebook Photo.
1.1.1.30Property: AlbumId
A Facebook unique identifier of the album that the photo is part of.
1.1.1.31Property: Caption
The caption of the photo.
1.1.1.32Property: CreateDate
A date when the photo was first uploaded.
Definition: public DateTime CreateDate
1.1.1.33Property: Link
The photo link.
1.1.1.34Property: OwnerUserId
A Facebook unique identifier of user who owns the photo.
1.1.1.35Property: PhotoId
A Facebook unique identifier of the photo.
1.1.1.36Property: Picture
The actual image. Accessing this property will download the bytes of the
image and serialize into an image. This does require a small
performance hit.
1.1.1.37Property: PictureUrl
The url of this picture
FacebookEvent Class
This class represents a Facebook event.
1.1.1.38Property: Creator
The Facebook identifier of the user who created the event
1.1.1.39Property: Description
Description of the event
1.1.1.40Property: EndDate
The date that the events ends
1.1.1.41Property: EventId
The Facebook identifier of the event.
Definition: public string EventId
1.1.1.42Property: Host
The Facebook user id of the host of the event
1.1.1.43Property: Location
The name of the place where the event will take place.
1.1.1.44Property: Name
The name of the event
1.1.1.45Property: NetworkId
The Facebook identifier of the network that this event is a part of
1.1.1.46Property: Picture
The actual image associated with the event. Accessing this property will
download the bytes of the image and serialize into an image. This does
require a small performance hit.
1.1.1.47Property: PictureUrl
The url of this event’s picture
1.1.1.48Property: StartDate
The date and time when the event starts
1.1.1.49Property: SubType
The seconary group of event type.
1.1.1.50Property: TagLine
The tagline of the event if one was specified
Definition: public string TagLine
1.1.1.51Property: Type
The primary grouping of the event
1.1.1.52Property: UpdateDate
The Facebook user id of the person who created the album
Group Class
This class contains represents a Facebook group.
1.1.1.53Property: Creator
The Facebook identifier of the user who created the group
1.1.1.55Property: GroupId
The Facebook identifier of the group
1.1.1.56Property: Name
The user entered name of the group
1.1.1.57Property: NetworkId
The Facebook identifier of the network that the group is part of
1.1.1.58Property: Office
The address of the group’s office if it has one.
1.1.1.59Property: Picture
The actual image associated with the group. Accessing this property will
download the bytes of the image and serialize into an image. This does
require a small performance hit.
1.1.1.60Property: PictureUrl
The url of this group’s picture
1.1.1.61Property: RecentNews
Free form text describing recent news associated with the group
1.1.1.62Property: SubType
The seconary group of group type.
1.1.1.64Property: UpdateDate
The last date and time that changes were made to the group
1.1.1.65Property: Venue
The name of the venue where the group meetings occur
1.1.1.66Property: WebSite
The url of the website for the group.
GroupUser Class
This class contains represents a Facebook group.
1.1.1.67Property: GroupId
The Facebook identifier of the group
1.1.1.68Property: Positions
Collection of positions held by this user
Definition: public Collection<GroupPosition> Positions
1.1.1.69Property: User
The user object representing the profile of the user
1.1.1.70Property: UserId
The Facebook identified of the user
User Class
This class contains represents a Facebook user.
1.1.1.71Property: AboutMe
A string describing the user. Free form.
1.1.1.72Property: Activities
Free form text describing the activities this user is interested in.
1.1.1.73Property: Affiliations
A collection of Networks this user belongs to
1.1.1.74Property: Birthday
The day this user was born
1.1.1.75Property: Books
Free form text describing this user’s favorite books
1.1.1.76Property: CurrentLocation
The current location for the user
1.1.1.77Property: FirstName
The user’s first name
1.1.1.78Property: HometownLocation
The location of the user’s hometown
1.1.1.79Property: InterestedInGenders
A collection containing enum values representing the genders that this
person is interested in.
1.1.1.81Property: InterestedInRelationshipTypes
A collection containing enum values representing the types of
relationships that this person is interested in.
1.1.1.82Property: LastName
The user’s last name
1.1.1.83Property: Movies
Free form text describing the user’s favorite movies
1.1.1.84Property: Music
Free form text describing the user’s favorite music
1.1.1.85Property: Name
The user’s name
1.1.1.86Property: NotesCount
The number of notes this user has associated with their Facebook
account.
1.1.1.87Property: Picture
The actual image associated with this user’s profile. Accessing this
property will download the bytes of the image and serialize into an
image. This does require a small performance hit.
1.1.1.89Property: PoliticalView
An enum value representing the user’s political view
1.1.1.90Property: Quotes
Free form text representing the user’s favorite quotes
1.1.1.91Property: RelationshipStatus
An enum value representing the user’s current relationship status.
1.1.1.92Property: Religion
Free form text representing the Religion
1.1.1.93Property: SchoolHistory
A data object representing the user’s education history
1.1.1.94Property: Sex
The user’s gender
1.1.1.95Property: SignificantOtherId
The Facebook user id of this user’s significant other
1.1.1.96Property: TVShows
Free form text describing this user’s favorite TVShows
1.1.1.98Property: WallCount
The number of messages that have been written on this user’s wall.
1.1.1.99Property: RelationshipStatus
The Facebook identified of the user
1.1.1.100Property: WorkHistory
Collection of Work object representing this user’s employment history
SchoolHistory Class
This class contains Facebook user’s education history (including high school
and college).
1.1.1.101Property: HigherEducaton
A collection of HigherEducation object representing the colleges this user
attended.
1.1.1.102Property: HighSchool
A HighSchool data object containing information about the high schools
this user attended.
HighSchool Class
This classs contains information about the high schools this user attended.
1.1.1.103Property: GraduationYear
The year this user graduated from college
1.1.1.104Property: HighSchoolOneId
The Facebook unique identifier of the high school
Definition: public string HighSchoolOneId
1.1.1.105Property: HighSchoolOneName
The name of the high school
1.1.1.106Property: HighSchoolTwoId
The Facebook unique identifier of the high school
1.1.1.107Property: HighSchoolTwoName
The name of the high school
HigherEducation Class
This class contains Facebook user’s college education history.
1.1.1.108Property: AttendedFor
An enum value representing if the school was attended for under
graduate work or graduate work
1.1.1.109Property: ClassYear
Graduation year
1.1.1.110Property: Concentration
A collection describing user’s majors
1.1.1.111Property: School
The name of the school
Network Class
This class contains the information about a Facebook Network.
1.1.1.112Property: Name
The name of the network.
Definition: public string Name
1.1.1.113Property: NetworkId
The Facebook unique identifier of the network.
1.1.1.114Property: Status
The status of the network (Open or Closed).
1.1.1.115Property: Type
An enum value representing the type of the network (College, High
School, Work or Region)
1.1.1.116Property: Year
The year associated with the network.
Location Class
This class contains information about a geographic location.
1.1.1.117Property: City
A city of the location.
1.1.1.118Property: Country
A country of the location.
1.1.1.119Property: State
A state of the location.
1.1.1.120Property: StateAbbreviation
A postal abbreviation of the state of the location.
Work Class
This class contains Facebook user’s work history.
1.1.1.122Property: CompanyName
The name of the company.
1.1.1.123Property: Description
The description of job.
1.1.1.124Property: EndDate
The date that the user ended this employment.
1.1.1.125Property: Location
The location of the job.
1.1.1.126Property: Position
The user’s position/title.
1.1.1.127Property: StartDate
The date the user started the job.
Visual C#
using System.Collections.Generic;
using System.Collections.ObjectModel;
…
Collection<User> friends = FacebookService1.GetFriends();
Visual Basic
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
…
Visual C#
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Facebook.Controls;
…
friendList1.Friends = FacebookService1.GetFriends();
Visual Basic
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports Facebook.Controls
…
friendList1.Friends = FacebookService1.GetFriends()
Visual C#
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Facebook.Controls;
friendList1.Friends = friends;
profile1.User = friends[0];
friendList1.FriendSelected += new
EventHandler<FriendSelectedEventArgs>(friendList1_FriendSelected);
…
void friendList1_FriendSelected(object sender,
FriendSelectedEventArgs e)
{
profile1.User = e.User;
}
Visual Basic
friendList1.Friends = friends
profile1.User = friends(0)
AddHandler friendList1.FriendSelected, AddressOf
friendList1_FriendSelected
…
Private Sub friendList1_FriendSelected(ByVal sender As Object, ByVal e
As FriendSelectedEventArgs)
profile1.User = e.User
End Sub
3. Store the user’s session information for making calls to the Facebook
service.
Visual C#
// When the user uses the Facebook login page, the redirect back
here // will will have the auth_token in the query params
string authToken = Request.QueryString["auth_token"];
if (!IsPostBack)
{
// Use the FacebookService Component to populate Friends
MyFriendList.Friends = _fbService.GetFriends();
}
Visual Basic
' ApplicationKey and Secret are acquired when you sign up for
_fbService.ApplicationKey = "7a399eeba47b0f5b2bfd88cc872ada4a"
_fbService.Secret = "fad3d3fbeb8571957c39e2792073b978"
_fbService.IsDesktopApplication = False
' When the user uses the Facebook login page, the redirect back
here will will have the auth_token in the query params
Dim authToken As String = Request.QueryString("auth_token")
Response.Redirect("http://www.Facebook.com/login.php?api_key=" &
_fbService.ApplicationKey & "&v=1.0")
End If