Usage Instructions: Using the old Facebook Connect JS libraries

Is this the right set of instructions for you?

If you are using the old-style Facebook Connect JS libraries (the src of your javascript will be something like: http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php), then this page is for you. If you are using the Open Graph API, please see Usage Instructions: Using the Open Graph API.

Overview

First of all, create an instance of FBConnectAuthentication, passing your Facebook Application's API Key and Secret, then call the Validate and GetSession methods from within a web request. The authentication and is done automatically using the cookies in the request, and most importantly, the Facebook Connect signature is verified.

Example

You can use Facebook Connect Authentication for ASP.NET by adapting the following example:

FBConnectAuthentication auth = new FBConnectAuthentication(apiKey,appSecret); //Note this is the "api key"
if (auth.Validate() != ValidationState.Valid)
{
    // The request does not contain the details of a valid Facebook connect session - you'll probably want to throw an error here.
}
else
{
    FBConnectSession fbSession = auth.GetSession();
    string userId = fbSession.UserID;
    string sessionKey = fbSession.SessionKey;
    // These values can now be used to communicate with Facebook on behalf of your user - perhaps using the Facebook Developer Toolkit
    // The expiry time and session secret is also available.
}

Last edited Jun 16, 2010 at 7:34 PM by ACreeger, version 4

Comments

No comments yet.