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

Setting Info Sections

Problem

My app has collected some fantastic info about my users, and I’d like to add it to their Info tabs as structured data.

Solution

The mid-2008 Profile redesign introduced the ability for applications to add sections to the new Info tab, accomplished through a new family of four API calls and a new FBML tag.

Setting an Info section is fairly simple, though the nested arrays can be a little confusing:

$info_fields = array(
    array(
        'field'=>'Favorite Naps',
        'items'=>array(
            array(
                'label'=>'Disco Nap',
                'link'=>'http://apps.facebook.com/superdisconapping/define/disconap'),
            array(
                'label'=>'Super Disco Nap',
                'link'=>'http://apps.facebook.com/superdisconapping/
define/superdisconap'),
            array(
                'label'=>'Power Nap',
                'link'=>'http://apps.facebook.com/superdisconapping/
define/powernap'))),
    array(
        'field'=>'Favorite Napping Locales',
        'items'=>array(
            array(
                'label'=>'Car',
                'link'=>'http://apps.facebook.com/superdisconapping/locale/car'),
            array(
                'label'=>'Office',
                'link'=>'http://apps.facebook.com/superdisconapping/
locale/office'))));

$infoResult = $facebook->api_client->profile_setInfo('Super Disco
 Napping', 1, $info_fields, 12345);

If you read down from the top, info_fields is an array that contains a field name and an array of items. Each item contains, at a minimum, a label and a link, but can also contain image, description, and sublabel fields (the example here keeps it simple and uses only label and link). The actual call to Profile.setInfo() accepts a name for the ...

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