Last updated 10 November 2015. Created on 27 September 2010.
Edited by ashish_nirmohi, Chroid, mengi, autolyst. Log in to edit this page.

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:

  1. The Drupal for Facebook project file from Choose the appropriate version for your version of Drupal.
  2. Facebook's PHP SDK libraries here:


  1. Unpack the most recent release of the FB module into /sites/all/modules/fb directory on your server.
  2. 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';

Theme Change

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="" 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 <html></tag>.

The final tag might look like:

<html xmlns="" xml:lang="<?php print $language ?>" lang="<?php print $language ?>" xmlns:fb="">

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="" 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.

  1. fb.module, listed as "Facebook API". This module alone is sufficient for social plugins such as the Like button.
  2. 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.
  3. 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:

Looking for support? Visit the forums, or join #drupal-support in IRC.


jlscott’s picture

I needed to add the line:

<script src=""></script>

to my page (ahead of the XFBML tags) to get the like button to work.

I note that the fb module is adding code to the bottom of the page, that is similar, but not the same as the line I added. Maybe something has changed at Facebook.

jlscott’s picture

I have just upgraded to RC13, and my page now works without the extra "script" tag.


Dave Cohen’s picture

Do NOT add a script tag like that. That will cause the JS SDK to initialize without any knowledge of the application you've configured.

Facebook's documentation will often suggest adding a tag like that. But never do that when you are using modules/fb.

tpainton’s picture

I have to add the script as well to get the like button to work. RC13 doesn't fix this for me.

grayb’s picture

I had the same problem. Had to add the script above into my html.tpl.php to get anything facebook related to work. Worth noting I'm on D7

tpainton’s picture

As noted in the issue queue, the script may very well cause other problems. The problem appears to be fixed in 6dev.. not sure about d7.

edglazer’s picture

Just a note here in case it helps someone troubleshoot, the latest facebook-php-sdk (3.0.1 at the time of this writing) actually causes a Fatal error:

Call to undefined method Facebook::getSession() in .../sites/all/modules/fb/fb.module on line 193

Instead, use the php-sdk v2.1.x branch (I used 2.1.2). That worked for me using Drupal 7.2 fb v3.x

dustyfox’s picture

thanks edglazer I just couldn't figure out what the problem was and thought for certain this version used sdk3.

dropbydrop’s picture

I had the same problem. That must be written in documentation!

luist’s picture

I had the same problems mentioned here, and I solved using <script src=""> </ script> (tanks jlscott) and setting in admin/config/content/formats/full_html unchecking Correct faulty or incomplete HTML. I hope this bug is corrected soon.

dcrsys’s picture

Just installed this module on a test server (drupal 6).

Installed everything as per instructions, inserted fb tags and nothing.
Added the script tag to the header of my page.tpl and everything starts working.
Is D6 not getting fixes?

FWIW I used this script in the footer to achieve the same result (facebook's preferred method I think - for now):

<div id="fb-root"></div>
  window.fbAsyncInit = function() {
    FB.init({appId: 'YourAppId', status: true, cookie: true,xfbml: true});
  (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
zatarain21’s picture

Now I am testing with Drupal 7.9 and fb 7x 3x Octuber 2011 and you don't need to add nothing. The like botton work great!!!

WhiteX’s picture

If you have Acquia Drupal (7.x), and want to use xfbml, make sure you have unchecked the filters at the FullHTML text format !( - Without this adjustment Drupal will strip the <fb:like></fb:like> tags ==> <like></like> which are not working... (even if you've selected the FullHTML text format!)

gianfrasoft’s picture

Thaks, WhiteX.

Web Software Engineer at
Insem S.p.A. -

bdoyle’s picture

I had to uncheck "Correct faulty and chopped off HTML."

rohr’s picture

You're the man. Thanks bdoyle.

markandphil’s picture

Same problem here! unchecking all filters fixed it in Drupal 7

alamave’s picture

Below is the message I got while going through the installation process.

Notice: Use of undefined constant FB_APP_OP_EVENT - assumed 'FB_APP_OP_EVENT' in fb_devel_fb() (line 273 of /hermes/web10/b741/pow.alamave/drupal710lagrohighschool/modules/fb/fb_devel.module).

pelach’s picture

enable the fb_app module.

cwtudor’s picture

Home » Administration » Configuration » Content authoring » Text formats

Full HTML and uncheck Correct faulty and chopped off HTML