fb:ref is a way to set a placeholder on a bunch of user profiles, and then update it across all those profiles with a single call. It makes sense to use when you have data or images that would need to be updated occasionally, but are not specific to the current viewing user. Some examples would be banner, application news updates, or perhaps an entire theme for a profile box.
You can have multiple fb:ref's - they are keyed off the one of two things:
- A callback url. In this case, you use the <fb:ref> to place the block, and the fbml_refreshRefUrl() to update it.
- A handle name. In this case, you use <fb:ref> to place the block, and fbml_setRefHandle() to update it.
Below, I will show steps for implementing the callback method:
- Set users' profiles with code like this:
$fbml = "<fb:ref url='http://yourserver.com/callbackurl' />"; $facebook->api_client->profile_setFBML("", NULL, $fbml, "", "");
on Bebo it would be:
$snml = "<sn:ref url='http://yourserver.com/callbackurl' />"; $bebo->api_client->profile_setSNML($snml , $userid);
For the callback url, you can either use a unique page or just pass a GET parameter that you can check for later like this:
<fb:ref url='http://yourserver.com/yourapp/callbackurl/?refcallback=1' />
- In the callback page, add some code the detects that it is the refresh, and updates the ref block:
if ( isset($_GET['refcallback']) ) { $text = " <div> <img src='http://yourserver.com/yourapp/someimage.jpg'/> </div> "; echo $text; }
- When you want to update the ref in all the profiles, call:
$refreshURL = "whatever you used for the sn:ref above"; $facebook->api_client->fbml_refreshRefUrl("$refreshURL");
on Bebo it would be:
$refreshURL = "whatever you used for the sn:ref above"; $bebo->api_client->snml_refreshRefUrl("$refreshURL");
Tags:
Programming
Post by John Maver
May 6, 2008
May 6, 2008