Getting and Setting Profile FBML


I want to get and set the contents of my users’ Profile Boxes and Profile Action links.


Use the Profle.getFBML() and Profile.setFBML() methods to manipulate the contents of your app’s Profile Box.


The process of setting FBML is similar to the process that takes place behind the scenes when a user requests a page from your app (see Under the Hood: How Facebook Apps Work). In this case, the process is less symmetrical, since you initiate an update to Facebook’s cache that they’ll later display. The FBML update flow is illustrated in Figure 9-17.

FBML update flow

Figure 9-17. FBML update flow

The FBML you set is cached on Facebook’s servers to make displaying Profiles as quick as possible, so you’ll need to use Profile.setFBML() again if you want to update the cache:

  1. Whenever your app feels the need to update Profile FBML, you call Profile.setFBML() from your app server and send your new content to Facebook’s servers, where it gets cached. This generally happens either because you have a user currently logged in who has done something Profile-worthy, or because you have a scheduled job (possibly using cron) that has resulted in a calculation.

  2. A visitor to one of your users’ Profiles requests the page from Facebook.

  3. Facebook renders your cached FBML into HTML (along with all of the other cached Profile Boxes and Action links for this user) and serves ...

Get Facebook Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.