Last updated December 8, 2010. Created by stacywray on October 5, 2010.
Log in to edit this page.

Building Facebook Applications can be a complicated process. We couldn't possibly write a one-size-fits-all description of how to configure all apps. So, in this section we describe a few commonly-required features and how to implement them with Drupal for Facebook.

Begin with the general installation and setup. Then, follow the instructions here to implement additional features.

Note: In general, if you plan on creating any kind of Facebook application (which we assume you are!), you must enable the fb_app.module (listed as Drupal for Facebook Applications in /sites/all/modules) and fb_user.module (Drupal for Facebook User Management).

To support applications beyond simple social plugins, you must enable clean URLs by going to admin/settings/clean-urls on your site. If you don't, some links that Drupal creates will not work properly on FB Application (canvas) pages.

To support Drupal websites integrating FB features (FB Connect), enable the fb_connect.module.

To support FB Application (Canvas) pages, enable the fb_canvas.module.

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

Comments

In the module fb_example, there is this function which adds a Like button to all node pages:

<?php
/**
* Implements hook_link().
*
* Add an XFBML like button to all node pages.  The button will appear next to
* other node links, such as "add new comment".
*/
function example_link($type, $object, $teaser = FALSE) {
  if (
$type == 'node' && !$teaser) {
   
$items = array();
    if (
variable_get('example_link_add_like', TRUE)) { // Switch to control this behavior.
     
$url = fb_scrub_urls(url('node/' . $object->nid, array('absolute' => TRUE)));
     
$items['dff_like'] = array(
       
'title' => "<fb:like send="true" ref="node/$object->nid" href={$url}></fb:like>",
       
'html' => TRUE,
      );
    }
    return
$items;
  }
}
?>

However, according to these conversion notes: http://drupal.org/update/modules/6/7#node_links
the hook_link() is deprecated. So I have tried to replace it with something like this:

<?php
/**
* Implements hook_node_view().
*
* Add an XFBML like button to all node pages.  The button will appear next to
* other node links, such as "add new comment".
*/
function example_node_view($node, $view_mode, $langcode) {
  if (!
$node->teaser) {
   
$links = array();
    if (
variable_get('example_link_add_like', TRUE)) { // Switch to control this behavior.
     
$url = fb_scrub_urls(url('node/' . $node->nid, array('absolute' => TRUE)));
     
$links['dff_like'] = array(
       
'title' => "<fb:like send="true" ref="node/$node->nid" href={$url}></fb:like>",
       
'html' => TRUE,
      );
    }
   
$node->content['links'][$node->type] = array(
     
'#theme' => 'links__node__' . $node->type,
     
'#links' => $links,
     
'#attributes' => array('class' => array('links', 'inline')),
    );
  }
}
?>

However the FB Like button does not appear at the end of the nodes. I don't have much experience neither with Drupal API nor with FB API, so I can't understand what is going wrong and how to fix it. Do you have any idea? Has anybody used the module fb with Drupal 7?

Also, Invite Friends and Invite to Page blocks do not appear at all on the list of blocks.
It seems that there is still some code that needs to be upgraded to D7.

Turns out that there is no such a thing like $node->teaser . Instead it should be:

<?php
 
if ($view_mode == 'full') {
    . . .
  }
?>