O'Reilly logo

Facebook Cookbook by Jay Goldman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting and Setting Profile FBML

Problem

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

Solution

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

Discussion

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required