How do I set the profile box FBML?

Nov 13, 2008 at 7:02 PM
How do I set the FBML of the current user's profile box FBML?

I'm referring to, in Facebook, Profile -> Boxes tab -> box for my application.  Thanks!
Nov 17, 2008 at 2:01 AM
You use the profile.setFBML method, and pass in the the FBML (Facebook version of HTML) for the boxes.

Assuming v2.0 of the toolkit, put the following in your canvas code (say Page_Load)

        if (string.Empty == API.data.getUserPreference(0))
        {
            // yourProfileBoxFBML is the FBML for the box in Boxes tab, and yourProfileMainBoxFBML is the narrower profile box that appears on the left-hand-side under wall and info tabs.
            API.profile.setFBML (0, yourProfileBoxFBML, yourProfileMainBoxFBML, null);
            API.data.setUserPreference(0, "profileBoxSet");
        }

The if stmt avoids setting the profile box multiple times.  To actually see the box appear, either the user has to give permission (in the Profile->Box permission) or you can prompt them with the following FBML:

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

See the smiley demo:

http://wiki.developers.facebook.com/index.php/Demos

Even though it's in PHP, the same concept applies.




Apr 7, 2009 at 2:35 PM
jshawsworld, thanks so much for that!

>> To actually see the box appear, either the user has to give permission (in the Profile->Box permission) ...

I've spent an hour on this problem, and probably would have been at it for a whole day, if I hadn't seen this!

Very nice post - thanks again!

Now, I'm heading back to Facebook Developers to answer the setFBML question for a couple a few guys who are stuck over there :)

Day 3 with this, and I've got "Hello, world" in the Profile Box. (but most of that time was spent battling the host, not the toolkit - which has so far worked pretty well).