Drupalcon notes: Facebook Applications in Drupal

Notes:  http://dave-cohen.com/

Facebook Application Development Platform

Facebook has done some basic verification on the users, with email addresses or CAPTCHA, so you're somewhat more assured of reaching real people. Obviously, you can tap into these users' social networks.

Dev platform was created in 2007. Allows anyone to add features to facebook.com. Early apps were aggressively viral; this has calmed down recently. Today it supports

  • Canvas Pages - appear inside facebook.com. Can contain just about anything, and any app can have any number of pages. Hosted remotely. Facebook Markup Language. (FBML) -- mostly like HTML but does have two changes.  1) you're only filling up part of the page, don't need body tag. 2) You also get facebook-specific tags like <fb:tabs> that let your page look like the rest of facebook pages.
  • Facebook Connect
  • Mobile apps

How do you build canvas pages using Drupal?

  • Pages are FBML, not HTML.
  • Links are all to http://apps.facebook.com...
  • Sessions controlled by facebook, not cookies. FBML is a type of XML.
  • There is precedent for Drupal building RSS feeds, which are XML
  • Better idea: produce FBML at the theme layer.
  • URLs map one-to-one -- apps.facebook.com/x/y/z and example.com/x/y/z are the same content and handled by the same callback
  • You have to edit your settings.php to provide some code that must run before bootstrap (fb_settings.php)

How does it work?

  1. User requests the apps.facebook.com page.
  2. FB makes a request to our server.
  3. Our server replies with the needed FBML data.
  4. FB passes the data back to the user

You'll have to enable an FBML theme. Don't forget it is only 760px wide. Javascript doesn't work right - FB wants to make sure you don't crap in their sandbox. Assume no jQuery will work. FBJS = Facebook Javascript, their version.

Facebook Connect

  • This module accelerates registration for your site. Gives you a "Connect with FB" button. Click it, get a modal, sign in with FB credentials. How this works:
  • User goes to your site.
  • Browser replaces XFBML tags you placed in with Facebook's results.
  • Build pages the drupal way.
  • Add xmlns:fb attribute to page template
  • Use XFBML in your theme, node, blocks ...
  • Call FB.Connect javascript classes.
  • User admin can be tricky. There's less to worry about overall than with canvas pages.
  • There are ways to embed flash using FBML but it's a bit tricky.

FB Connect brings social features to your website

Drupal For Facebook project

  • Provides bits for both types of pages.
  • Supports accounts
  • Wall posts
  • Profile tabs
  • Extended permissions and request forms
  • Integration with third-party modules, like Views
  • Extensible via hook_fb()
  • Enable the modules and edit settings.php

User issues

In drupal, users can be anon or reigsered. In Facebook apps users are either Not Authorized or Authorized. Once authorized we can see info about the user and their social groups, depending on their privacy settings.

  • Anon and Not Authorized: you know nothing about them
  • Registered but not FB Authorized: you know Drupal profile info but nothing else.
  • Anon on your site but authed on FB: we know social stuff but no local account. How to support this user? You can't use roles. Caching is a problem.
  • Registered locally and authed on FB: you've got a drupal profile AND a social graph.
     
all tags: