Oct
17
2008

Facebook has fully launched its new profile, forcing application developers to revisit the coding of a profile box. Fortunately, without making any changes whatsoever, the old style profile boxes will appear successfully on the Boxes tab.

However, for those application developers who want to go one step further, here is a description of how to support the profile box on the user’s Wall tab using the PHP library.

1. Client Library

First, make sure you have the latest client library. Visit the the Facebook client library wiki page for more information and a link to the download. Note that this library drops support for some old functions such as require_add, so if you haven’t kept your application up-to-date now is the time to do so. The PHP 5 version of the library contains the call you need. If you are using PHP 4 then you need to manually update the library call to look like this:

function profile_setFBML($markup, $uid = null, $profile=”, $profile_action=”, $mobile_profile=”, $profile_main=”) {
return $this->call_method(’facebook.profile.setFBML’, array(’markup’ => $markup,
‘uid’ => $uid,
‘profile’ => $profile,
‘profile_action’ => $profile_action,
‘mobile_profile’ => $mobile_profile,
‘profile_main’ => $profile_main));

2. Reset FBML

For the profile box to appear on the Wall tab you must load the FBML that will appear there. This is done using the same function that was used to load the old-style profile, only now there is a new parameter “profile_main”. In PHP, use the following code to load the profile boxes:

$fbml = "<fb:wide>This is a wide profile box on the Boxes tab.</fb:wide>";
$fbml .= "<fb:narrow>This is a narrow profile box on the Boxes tab.</fb:narrow>";
$fbml_main = "This is the Wall tab profile data";
$result = $facebook->api_client->profile_setFBML(NULL, $user_id, $fbml, NULL, NULL, $fbml_main);
echo "set FBML: result = ".var_export($result,true);

If your return code is NULL, all is well. If not, check the return codes documented on the wiki page.

3. Add to Profile Button

If you want to make it really easy for the user, program an “Add to Profile” button to appear on a canvas page. If the user has not yet added a profile box (on the Boxes or Wall tabs) and the FBML for profile_main was successfully loaded in step 2 then the button will appear. If there is already a profile box displayed, then the button will not appear. The code for the button is simple:

<fb:add-section-button section="profile" />

Note this cannot appear within the dashboard.

That’s it! You should now have the ability to display a profile box on either the Wall tab or the Boxes tab.

22 Responses to “New Facebook Profile Boxes”

  1. Danny says:

    Hey Bev,

    I might be a bit over my head here. I’m trying to build profile wall tabs for some clients using Static FBML. I just downloaded PHP5.

    I’m trying to understand how this works and based on everyone else’s comments I am a few steps behind.

    I am not a software developer. I’m just trying to type in some code and have the FBML tabs show up on the narrow section of the wall.

    Thanks so much!

  2. Bev says:

    Hi Danny,

    Here is a tutorial about using static FBML (link)

    Hope this helps!