Back to News for Developers

Enhancing Your IFrame-based Applications

September 2, 2008ByRay C. He

Based on developer requests for greater flexibility and for better performance, we've added a number of new features for iframe canvas pages that provide them with much of the functionality previously available only to FBML-based applications. These features include:

  • Using XFBML, our extension to FBML that allows iframe-based application to use FBML tags.
  • The availability of cached friend lists and preload FQL data to the JavaScript client library.
  • The ability to preload FQL queries, just like FBML-based applications have been able to do.

You can now use FBML tags on iframe canvas pages with XFBML. Many tags, like fb:name and fb:profile-pic, you can incorporate directly into your iframe's HTML. Other important tags, like fb:request-form, you can use within the fb:serverfbml tag, letting you incorporate multi-friend selectors and request forms right into your iframe. If you're trying out Facebook Connect, you might already be familiar with XFBML, and now these same features are available for all iframe applications.

You can access friend lists faster using the standard JavaScript client library'sFB.Facebook.apiClient.friends_get(callback) call. This call detects if the data is already rendered on a canvas page, avoiding a server request and loading the data instantly through the cross-domain communication channel. Any preloaded FQL data requested with the REST API admin.setAppProperties call is also rendered on canvas pages and can be accessed via the JavaScript client library's FB.Facebook.apiClient.preloadFQL_get(callback) call, which gets the data in the same way. The argument passed to callback is an associative array with requested rule names as keys and JSON-encoded query results as values.

In addition to the JavaScript client library changes, iframe applications that want to preload FQL queries will receive the data along with other parameters via POST with the prefix 'fb_post_sig’. We’re using a different prefix from the original 'fb_sig' prefix so we can avoid namespace collisions with the GET parameters, which will continue to use 'fb_sig' for compatibility with current applications which may be expecting the data. These parameters can be accessed and validated in the same method as the old parameters (for the PHP client, use get_valid_fb_params with the new fb_post_sig prefix).

The PHP client library has been updated to combine the new parameters so they can be accessed as part of the fb_params.

We hope that this new functionality will assist developers in creating faster applications for a better user experience. Please send us any feedback and share your thoughts with the community in the Developer forum.