A brief example of how to use fb:ref on Facebook or sn:ref on Bebo

John Maver
Written by John Maver  ()
on July 27, 2018 ·


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:

  1. A callback url. In this case, you use the <fb:ref> to place the block, and the fbml_refreshRefUrl() to update it.
  2. 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:

  1. Set users' profiles with code like this:
      $fbml = "&lt;fb:ref url='http://yourserver.com/callbackurl' /&gt;";
      $facebook->api_client->profile_setFBML("", NULL, $fbml, "", "");

    on Bebo it would be:

      $snml = "&lt;sn:ref url='http://yourserver.com/callbackurl' /&gt;";
      $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:

      &lt;fb:ref url='http://yourserver.com/yourapp/callbackurl/?refcallback=1' /&gt;
  2. In the callback page, add some code the detects that it is the refresh, and updates the ref block:
      if ( isset($_GET['refcallback']) ) {
        $text = "
            &lt;img src='http://yourserver.com/yourapp/someimage.jpg'/&gt;
        echo $text;
  3. When you want to update the ref in all the profiles, call:
      $refreshURL = "whatever you used for the sn:ref above";

    on Bebo it would be:

       $refreshURL = "whatever you used for the sn:ref above";

Topics: Programming

Follow us:

Enjoy this article? Don't forget to share.

Interested in Working With Us?

Click Here to Find Out More About How We Can Help You