How to generate facebook infinite session

May 30, 2008

When developing facebook applications, we might need an infinite session that will enable us to update the app users’ profile periodically. For instance, a “Quote Of TheDay” application needs to update its users’ profile everyday with a new quote.

Here are the steps to generate an infinite session that does not expire. Note: these steps only need to be done by the developer once; no action is needed from the app users.

  • Login to your own facebook account.
  • Browse to: http://www.facebook.com/code_gen.php?v=1.0&api_key=YOUR_API_KEY (replace YOUR_API_KEY with your app’s API key) Click through the simple instructions on the page. After that, you’ll be provided with a one-time code like 5P4I8D .
  • Invoke facebook API auth.getSession using the one-time code. The returned result will be the infinite session key.

Source of info: http://wiki.developers.facebook.com/index.php/Authentication_guide


How to stay in facebook Page context

May 30, 2008

When developing Facebook application for Pages, it is mandatory to “stay in Page context” in order for <fb:page-admin-edit-header/> to be rendered. Thanks to Thought Labs Blog, for documenting the way to do so:

you MUST add the ‘fb_page_id=[pageID]‘ URL param to the POST URL.


How to display PHP compilation errors

May 30, 2008

It’s frustrating when PHP compilation errors are not shown during development. To make such compilation errors visible on the web pages, add this line in .htaccess:

php_value display_errors 1

Alternatively, if access to .htaccess is not allowed, this PHP code achieves the same result too:

ini_set(’display_errors’,1);