The installation of Drupal for Facebook is not the same as all other Drupal modules. So please pay close attention to the steps below.
You will need to download two files:
- The Drupal for Facebook project file from http://drupal.org/project/fb. Choose the appropriate version for your version of Drupal.
- Facebook's PHP SDK libraries here: https://github.com/facebook/facebook-php-sdk
- Unpack the most recent release of the FB module into /sites/all/modules/fb directory on your server.
- Unpack Facebook's most recent PHP SDK libraries into the /sites/all/libraries/facebook-php-sdk directory on your server.
If for some reason you need to install Facebook's libraries in some other directory on your server you must tell modules/fb where to find it. Edit your settings.php to include a line similar to this (add this to the end of section where the $conf variable is defined and hange the path to exactly where you placed facebook.php):
$conf['fb_api_file'] = 'sites/all/libraries/facebook-php-sdk/src/facebook.php';
In order to support Microsoft Internet Explorer (IE) it is necessary to make this small change to your theme. If you're not using IE right now you can come back to this later. If you are using IE you might want to re-evaluate your whole life and also make this change.
In order to display XFBML tags IE requires the attribute:
xmlns:fb="http://www.facebook.com/2008/fbml" in the
<html> tag, which is part of your theme. Manually edit your theme's page.tpl.php file, adding that attribute alongside the others in the
The final tag might look like:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language ?>" lang="<?php print $language ?>" xmlns:fb="http://www.facebook.com/2008/fbml">
Note the exact tag will vary depending on the theme you use. So it is best to find the
<html> tag near the top of page.tpl.php and edit it, adding just:
xmlns:fb="http://www.facebook.com/2008/fbml" to the end of that tag.
Note the page.tpl.php file is still used in Drupal 6, but html.tpl.php has been introduced with Drupal 7 and it is located in modules/system/html.tpl.php and contains the html header information.
Enable the Drupal for Facebook Modules
Under Admin >> Site Building >> Modules, you'll see that Drupal for Facebook comes with a number of modules. For now let's enable just what we need to get started.
- fb.module, listed as "Facebook API". This module alone is sufficient for social plugins such as the Like button.
- fb_devel.module, listed as "FB Development Tools". This module tries to warn you of potential errors before they happen, and has additional tools we'll enable later on. You will need the Devel module as described on the Prequisites page. You should disable fb_devel.module on your live server only after you are certain Facebook features are working.
- Note: In Drupal 7 you will want to enable the fb_app.module (listed as "Facebook Apps") as the fb_devel.module is dependent on it.
As always, after enabling a new module, go to Admin > User Management > Permissions and give appropriate role permission to administer applications.
Confirm That It Works
To quickly confirm that XFBML tags now work, place this markup in a page node (or block) on your website. In the body field type in the code shown here:
Note: When placing this markup in a node or block, you must choose an appropriate input format. That means don't leave the default "filtered html", instead choose "full html" or "php". Otherwise, Drupal will strip the
<fb:like> tag before rendering the page. In some cases, even in "full html", you may need to uncheck "Correct faulty and chopped off HTML."
Once you save the configuration, you will see the Facebook Like button as shown below: