Update of DrupalForFacebook.org

I've updated the DrupalForFacebook.org website to the latest version of both Drupal (7.x) and modules/fb (4.x). The updated tour shows features of the latest version. And as always, this site is a live example. So when you click the facebook connect button at the top of this page, you're using Drupal for Facebook. If for any reason you need to visit the old version of this site, it's still running, now at www.drupalforfacebook.org/d6. Please refer to that as a read-only site. If you want to post to the forums, please do so here. If you notice any problems with the upgrade, please let me know. Thanks and enjoy Drupal for Facebook.

July 2013 Breaking Changes

I've received several warnings from facebook recently. The warnings say something like: Your app, [App Name] has not enabled the migration for the July 2013 Breaking Changes. ... [App Name], is currently using the following deprecated features: Social Plugins (Like Button, Like Box) without absolute URL's in their `href` parameter. Like buttons and other social plugins produced by Drupal for Facebook already use absolute hrefs. I have yet to find a single social plugin using a relative href in any of the apps which facebook is warning me about. So, I'm pretty confident that facebook's warning system, while trying to help, is flat out broken and causing developers to worry about nothing. That said, if you've installed Drupal for Facebook and have manually set up a block or content with a social plugin tag in it, you should double-check that all your hrefs are absolute and not relative. Also, if anyone can find an actual example of a relative href being rendered by Drupal for Facebook, please let me know. As far as I know this has not been a problem and no updates to your Drupal system are necessary.

Logout link problems when facebook connected

Drupal sites using fb_connect.module may notice a new problem. The logout link doesn't appear to work until it is pressed twice. If that affects your server, please try the latest build. There's a fix in the latest .dev build of Drupal for Facebook. Please test and I'll make a new release soon with this fix in it. For more details, see: https://drupal.org/node/1926970

February 2013 Breaking Changes

Some users of Drupal for Facebook may have received an email today, a warning from facebook that they have 1 day to address a potential problem. For most users, you are seeing this notice because modules/fb uses admin.getAppProperties on admin pages. The change to admin.getAppProperties is minor and should not break anything. In short, for most Drupal for Facebook users, it is perfectly save to enable the Feb 2013 Breaking Changes, and doing so will remove the alert from Facebook. You should look over the entire list of Feb 2013 changes. Some applications could potentially be affected by other items there. The majority of Drupal for Facebook users will not be.

Generate Facebook Access Tokens (shell script)

I'm often asked how to get an access token that allows a Drupal website to post to a facebook page. Not long ago, facebook deprecated the offline_access permission. In doing so, they made this process relatively complex. This Facebook token generator script attempts to walk you through the process. Although Drupal for Facebook has some token generation tools built-in, this script can be used by a user who has privileges on facebook (i.e. to manage a page) but not privileges to administer Drupal. Developers, feel free to suggest patches to the script. It could be made easier and prettier.

Fix for XFBML.parse() or Mysterious Javascript Errors

For those of you noticing strange javascript errors or exceptions thrown by XFBML.parse() that started appearing in last few days... These changes come from recent changes facebook made to their javascript API. The latest builds of Drupal for Facebook have a workaround. I recommend upgrading ASAP. Either download the latest 3.x-dev build for your version of Drupal. Or download the latest release for you version of Drupal. (Note that drupal.org does not always display the latest version on the project homepage, see https://drupal.org/node/178857/release)

"This connection is untrusted" error - and how to work around it

A couple users have reported problems viewing canvas pages on Drupal for Facebook. The error is "This connection is untrusted" or something similar to that (depending on the browser). The problem is that, although the site has a certificate for HTTPS, that certificate is not signed by an authority already trusted by your browser. This site uses a self-signed certificate, rather than pay exorbitant fees to some authority that most browsers already trust. We support HTTPS only because facebook recently started requiring that, not because we're asking for credit cards or any sensitive information. Here's a quick way to get past the error.
  1. First, visit this page over HTTPS. Your browser will give you a warning. Again, this is because the cert is self-signed. Click through the warning, allowing your browser to visit the page. This will not make your browser less secure in any way. It will merely allow the browser to visit this domain over HTTPS.
  2. Next, visit a canvas version of this page. You should no longer see any error.
I recognize its a pain to ask users to do this. But until I sort out the certificate situation, it will allow you to demo this site and follow all of the tour. Thanks for understanding.

Help Test Drupal for Facebook

I'm testing a pretty big change to Drupal for Facebook. If you have a moment, please help me test by logging into (and out of) www.drupalforfacebook.org. Let me know whether everything works, or not, and what browser your using. Thanks! For more details, see http://drupal.org/node/1679924.

Drupal for Facebook - The Next Release

Modules/fb has a long (sometimes arduous) history. Integrating Drupal with Facebook's platform basically since the platform became available. Back then, all Facebook apps were what we now call "canvas pages"; Facebook Connect did not exist. Canvas pages were written in FBML, whereas now they are iframes. Facebook has completely changed their PHP and Javascript SDKs, and introduced the "Open Graph". In short, these modules have changed a lot over the last couple years. Almost every feature has been reimplemented once or twice. As with most software projects as they get older, it's tempting to do a complete rewrite. Doing so would clean out the obsolete bits of code that are no longer used, or no longer best practice (or no longer working at all). Here are some thoughts about what this rewrite-from-scratch might look like.
  • No Dependency on PHP SDK -- Fortunately Facebook's platform has evolved to be based entirely on internet standards. Most interaction is based on JSON over HTTP. Drupal already has helper functions for these protocols, which modules/fb can use instead of what facebook provides. Frankly I expect Drupal's code to be more reliable, better implemented and supported. Plus the modules would be self-contained, not requiring an extra download as part of the install process.
  • Less Canvas Page Code -- Initially, app were all canvas page, and canvas pages were difficult to support. These days, they are iframes, which makes them basically a regular web page. They are not restricted to just 760px. Drupal already does a good job serving them up. It might be possible to eliminate fb_canvas.module entirely.
  • Less Application Configuration -- Once upon a time, modules/fb could create an app for you. You never had to visit facebook.com, cut and paste IDs and SECRETs etc. That's no longer possible, and facebook has a bunch of properties associated with apps that Drupal cannot modify. In short, you basically have to visit facebook.com to configure your app. And the tools provided by facebook are much better than they used to be. So, modules/fb should work well with apps that are not configured via Drupal. There are some features, like posting to facebook, which do not even require that an application is hosted on Drupal.
  • Token Management -- These days, interaction to the facebook platform is all about tokens. There's a token for each user (or page) that uses an app. These tokens make features possible, even if Drupal is not configured with an application secret. So, as features become more dependent on tokens, modules/fb has to provide a clean and easy way to manage lots of tokens.
These are changes I have in mind for a next release (modules/fb 4.x). The goal being a cleaner, smaller set of code. Not supporting all the same features, its worth noting. I think its best to do away with the parts that may no longer be needed, don't work optimally and and hard to support. Even if doing so will lead to some headaches for users upgrading from the current version. That is, after all, the Drupal Way.

Timeline Activity on Drupal for Facebook

For a while now, the modules/fb/fb_graph.module has included some helper functions to publish user activity to a facebook timeline. And now this site is demonstrating those features. Here are the activities that may appear on your timeline:
  • Post - when you post new content to our forums, a link to the post will appear in your timeline.
  • Edit - when you edit a forum post, it will appear in your timeline as an edit.
  • Comment - when you leave a comment, that will also appear in your timeline, with a link back to the original post you commented on.
To enable/disable this feature, click the "my account" link (left), then click "edit" and check/uncheck the "Publish to Timeline" checkbox. To add features like this to your own website, it's a fairly involved process to register timeline actions. This is done through Facebook's developer application, and you should read their documentation thoroughly to understand it. You'll need to define both Graph items and Actions. On the Drupal side, modules/fb/fb_graph.module will help you both markup your pages with Graph metadata, and publish activity. To get a sense of what's involved, here are two snippets of code, both from a custom hook_nodeapi() function. When viewing a node, include Facebook Graph metadata:
<?php
 
if ($op == 'view' && $a4) {
   
// Full page view of a node.  Treat it as an article on facebook.
   
if (module_exists('fb_graph')) {
     
fb_graph_set_tag('og:type', 'article');
     
fb_graph_set_tag('og:title', $node->title);
     
fb_graph_set_tag('og:url', url('node/' . $node->nid, array('absolute' => TRUE, 'fb_canvas' => FALSE)));

      if (isset(
$GLOBALS['theme_key']) && ($logo_path = theme_get_setting('logo_path'))) {
       
// @TODO: does the node have its own image?                                                                          
       
$url = url($logo_path, array('absolute' => TRUE, 'fb_canvas' => FALSE));
       
fb_graph_set_tag('og:image', $url);
      }
    }
  }
?>
When creating/editing a node, publish the activity to facebook:
<?php
  
// This snippet relies on fb_graph.module to publish events to a user's timeline.
  // It will work only if you've configured your story nodes to be tagged as og:type article, and also you've configured post and edit actions.
 
if (($op == 'insert' || $op == 'update') &&
     
dff_custom_do_graph_publish($GLOBALS['user']) && // enable this only if you've defined read, edit and post actions.
     
$node->uid == $GLOBALS['user']->uid &&
     
$node->status &&
      (
$fbu = fb_facebook_user())) {
   
extract(fb_vars());
   
$url = url('node/' . $node->nid, array('absolute' => TRUE, 'fb_canvas' => FALSE));
    if (
$op == 'insert') {
     
$id = fb_graph_publish_action('post', array(
                                     
'article' => $url,
                                    ));
    }
    elseif (
$op == 'update') {
     
$id = fb_graph_publish_action('edit', array(
                                     
'article' => $url,
                                    ));
    }
  }
?>

Pages

Subscribe to Drupal for Facebook RSS