Creating a Facebook Application

Creating any facebook application (with or without drupal) is a 2 part process. The Application must first be created (think: registered) on facebook through the developers app, where it assigned key-codes to access the facebook API, and a facebook url in the form of http://apps.facebook.com/url-of-my-new-facebook-app. Part 2 is setting up the facebook application itself, which resides on your own server, which receives and sends data to facebook.

Creating the Application on Facebook.com

Note: You will have to create the application in Facebook first
http://apps.facebook.com/developers/

Creating your Facebook Application with the Drupal for Facebook module

Once you have the module installed correctly and set the proper permissions, you should see "Facebook Application" as a new content type under "Create content".
Create a new Facebook Application and fill out the form accordingly. You may not see all the fields described here, unless you have enabled all the Drupal for Facebook modules. If you're not sure what a setting means, reading the Facebook documentation will help, and the default values are usually appropriate.

Title

Identifies the application to site administrators.
You should be able to put any title you want here, it will not be used in the application itself.

Label

Used in the code, for naming styles, etc. A single Drupal installation can host more than one Facebook App; each needs a unique label. Use no spaces or weird characters.

Api Key

This is the first key that facebook assigns you when you register your application on developer.facebook.com. It allows your application to securely communicate with the facebook api.

Secret

This is the second key facebook assigns you. It will be used to encrypt your data as your application communicates with facebook.

Canvas Page Url Suffix

Type only the part that comes after "http://apps.facebook.com/"
i.e. myfacebookapp if they gave you http://apps.facebook.com/myfacebookapp

body

This is not used anywhere in the application yet. You can just leave it blank.

Facebook infinite session settings

See setting up infinite sessions below.

Facebook navigation settings

Here you can specific an app-specific frontpage. Otherwise, the sitewide frontpage will be used.

  • Front page when user is not logged in:
  • You could point this to any page on your site and it will be where someone going to http://apps.facebook.com/myfacebookapp will land who is not logged into your app. This could, for example, be a page describing to the user what your app does and why they would benefit from adding (or logging into) it.

  • Front page when user is logged in, but has not added the app.:
  • Like above, but for someone who is logged into your app but has not added it yet.

  • Front page when user has added this application.:
  • Like above, but for someone who has added your application to their facebook account ( which will allow you to post info in their profile, and in their news feed, etc).

Facebook user settings

  • Require Login
  • All users who visit your app canvas pages will be logged into facebook. This field is asking, "must they log into your app?" This is Facebook's way of making sure the user has granted the app permission to learn information about the user.

    If you want any facebook user to see the content of your app, select "allow anyone". You can always require the user to add the app to gain access to additional features.

    • Allow anyone - If the user has not logged in or added your app, you'll be able to learn very little about who they are. Also you wont have a persistant session, so form submissions, drupal_set_message(), etc. will not work properly.
    • Allow logged-in users - In this case you can learn the user's name and other information.
    • Allow users who have added this app to their profile - in this case you can write to the user's profile and news feed.
  • Not logged in user (uid):
  • You may create a user (for example, "Anonymous Facebook"), is you want to treat facebook users differently from the anonymous users who visit your site directly. I.e. you can give anonymous facebook users different permissions. Experimental and not guaranteed to work.

  • Logged in user (uid):
  • Similar to the above setting, if allowing logged in users and not creating a local account for them. Experimental.

  • Create Local Account: (required)
  • Do you want to create a Drupal account for the Facebook user who is visiting your app?

    • Never (I'll map the accounts some other way)
    • If user has logged in
    • If user has added this app
  • New user role (rid):
  • When a new account is created for a visitor to this app, what role should they be assigned. This allows you to assign permissions to the users who have added or logged into the app.

  • Make Local Account Unique
  • This is relevant when hosting multiple Facebook Apps on a single Drupal install. If a single Facebook user adds two apps, should two local accounts be created? Leave blank to have the multiple Apps share a single local account.

...Remaining options

More options may be available to you depending on what other modules you have installed. Look to their documentation for more information.

After submitting the form, the following page will specify the callback URL. Return to the Facebook Developer Application settings on your Facebook account. Make sure the callback URL is exactly identical to the one shown.

Viewing your Facebook Application

Once you've created the application, you should be able to view it at:
http://apps.facebook.com/myfacebookapp

where myfacebookapp is the suffix for your applications canvas page.

 
 

Drupal is a registered trademark of Dries Buytaert.