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.



Unfortunately it didn’t work for me, even though I copied verbatim what you provided (modifying the user id)
What part didn’t work? Did you get an return code from profile_setFBML? Are you missing the button?
Get the “No content to display.
This box will not be visible to people who view your profile until this application adds content to it.” message on the profile page. If its added to boxes it works, but if its on the side wall area it shows that message. Any ideas? Getting the NULL return code btw.
Adam, this could happen if you are not using the latest API library. The profile_main parameter will be ignored. Look in your library and make sure that looks 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));
I’m having the same problem. I am using the PHP4 version of the API library which has the profile_main parameter missing and I can’t find any other latest library for PHP4. Anyone got a solution for PHP4?
Facebook have not yet provided the API library for PHP4. You can try calling setFBML without using the API link:
$facebook->api_client call_method(‘facebook.profile.setFBML’, array(
‘uid’ => $user,
‘profile’ => $profile,
‘profile_main’ => $profile_main));
Thanks Bev. I couldn’t get it to work that way but I added profile_main to the profile_setFBML signature and it works so far.
hi
i got the latest version of the api library but somehow the function profile_setFBML was still the old one without the $profile_main parameter. I added this bit manually and now it works!
hey this isn’t working for me either
im getting the NULL return code for the first part
and the button is showing up
but when you click it to get the preview at the bottom img getting this error
“Fatal error: Call to a member function profile_setFBML() on a non-object in /home/pushm3/public_html/facebook/rss.php on line 41″ which is referring to this line
“$return = $facebook->api_client->profile_setFBML(NULL, $user_id, $fbml, NULL, NULL, $fbml_main);” in the script
ive no idea what that means have you got any ideas what could be wrong?
i tried adding the $profile_main parameter like this
“$return = $facebook->api_client->profile_setFBML(NULL, $user_id, $fbml, NULL, NULL, $fbml_main, $profile_main);”
but it didn’t work either
can you help me out?
many thanks
Ben – did you use the example I provided? If not could you show your code. I don’t see why the preview would be executing profile_setFBML, it should just be echoing the contents of the profile box.
Im in the middle of learning / developing something for facebook, using your info i learnt that they’d provided me with an out of date library, but ive also learnt it doesnt seem to pull any live data to the profile, does it only post the data to your profile that it initially grabs when you add the box to your profile or is their a way we can pull live data each time? I’d really appreciate a heads up thanks bev
Hi Kevin,
Whenever you call profile_setFBML you provide a snapshot of the contents of the profile box. It will not change until you make another call to profile_setFBML.
A more dynamic option is to implement a profile tab. The profile tab page is more like a canvas page.
Good luck with your app!
how do i refresh the profile box…i update a count via my app but in profile box nothing is updated…..any idea??? plz help…
Hi sheeraz,
My comment to Kevin above applies to your question also. You must call profile_setFBML to update the contents of the profile box.
Hi there,
After reading countless tutorials, including this one, I’m still no further to completing my VERY simple app. I must say, the Facebook Platform documentation is very dire. I have been having the same problem as described by many above, where the wall profile box display the ‘no content’ message.
I am using the most recent library (just downloaded it now), I checked the ‘facebookapi_php5_restlib.php’ for the function profile_setFBML and I was missing the $profile_main parts. After adding these in I am still at the same place, with my profile box showing no contents. Below is my code:
$fbml = “This is a wide profile box on the Boxes tab.”;
$fbml .= “This is a narrow profile box on the Boxes tab.”;
$fbml_main = “This is the Wall tab profile data”;
$return = $facebook->api_client->profile_setFBML(NULL, $user_id, $fbml, NULL, NULL, $fbml_main);
echo “set FBML: result = “.var_export($return,true);
I’d like to point out a typo in the tutorial in the var_export, it should be $return, not $result – I have changed this in my code. When I run this code I get:
set FBML: result = ’1′
But my profile box does not change. The boxes in the ‘boxes’ tab change perfectly, but the narrow box on the left of the wall do not. Any ideas?
Hi Mike,
Thanks for pointing out the typo, I have fixed it now.
It seems a lot of people have trouble getting profile_setFBML working for them. Some have resolved the problem by skipping the api and call the fbml directly. There is a thread discussing this here.
Please let me know if this helps.
By the way, the return code of 1 is not success, it indicates “an unknown error occurred”. Not terribly helpful but it does indicate something is wrong with your call.
hi, plz help me. i want to made a an application and want to “Add to Profile” button now showing. So that which file i can change and it is display.
Yogendrasinh, The code to show the “add to profile” button is:
<fb:add-section-button section=”profile” />
Your profile box data must be set up with profile_main data.
Hey,
I dont understand why this code always returns me “1″
(I only have this code in one page)
$fbml = “blah 1″;
$fbml .= “blah 2″;
$fbml_main = “This is the Wall tab profile data”;
$result = $facebook->api_client->profile_setFBML(NULL, $user_id, $fbml, NULL, NULL, $fbml_main);
echo $result;
I use the last version of php and api…
Hi Wery,
I take it that your profile box isn’t generated. There is some discussion on the wiki page for profile.setFBML that indicates error code 1 means success. In my experience I got a NULL return code.
Do any of the profile boxes update for you?
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!
Hi Danny,
Here is a tutorial about using static FBML (link)
Hope this helps!