Using fb:ref to Automatically Update an App With User-specific Data
by Joe Lanman
Overview
The fb:ref tag is your friend. It allows you to place a reference on a user's profile, and send content to this reference whenever you want.
Process
There are two types of fb:ref tag - handle and URL. Handle allows you change content directly, URL points to a script to get an update.
Using fb:ref handle
- Store a handle for each user (eg. user id) in a database or file
- Write a handle tag to the user's profile using profile_setFBML: <fb:ref handle="UNIQUE_HANDLE_HERE" />
- Write a script to loop through your handles and use facebook.fbml.setRefHandle("UNIQUE_HANDLE_HERE", "FBML_Content") to update
- Add a Crontab to run this script periodically
Using fb:ref url
- Store a handle for each user (eg. user id) in a database or file
- Write an update script , eg. update.php, to take a user handle as a parameter and render the relevant data
- Write a URL tag to the user's profile using profile_setFBML: <fb:ref url="http://www.mysite.com/update.php?handle=UNIQUE_HANDLE_HERE" />
- Write a script to loop through your handles and use facebook.fbml.refreshRefUrl("http://www.mysite.com/update.php?handle=UNIQUE_HANDLE_HERE") to update
- Add a Crontab to run this script periodically
Neither of these options require you to have the specific users logged in - but you must have your own infinite session enabled.