Search code examples
facebookiframefacebook-fqlfacebook-iframe

Facebook iFrame app - how to fetch Preload FQL result using PHP SDK?


since few years I have an FBML app (a small Flash game) which I'm now trying to convert to an iFrame app. Unfortunately there aren't many docs for Facebook iFrame apps yet.

For my game I need the user's first name, picture, gender and the city.

In my old version I had this preload FQL (created once by a PHP script):

$fql = array('info' => array('pattern' => 'facebook',
    'query' => 'SELECT first_name, sex, pic_big, current_location 
    FROM user WHERE uid={*user*}'));

$fb->api_client->admin_setAppProperties(
    array('preload_fql' => json_encode($fql)));

and then my FBML app script had been as simple as:

<?php

require_once('facebook.php');

define('FB_API_ID', 'XXX');
define('FB_AUTH_SECRET', 'YYY');

$fb         = new Facebook(FB_API_ID, FB_AUTH_SECRET);
$viewer_id  = $fb->require_login();
$data       = json_decode($fb->fb_params['info'], true);

$first_name = $data[0][0];
$last_name  = $data[0][2];
$female     = ($data[0][3] != 'male');
$avatar     = $data[0][3];
$city       = $data[0][4]['city'];

# and then I'd just construct flashvars attribute
# for the <fb:swf ...> tag and print it

?>

Does anybody please have hints on how to recreate the same script for the iFrame version - i.e. how can I fetch the result of Preload FQL by my iFrame app?

According to an older Facebook blog entry Preload FQL should be accessible by the iFrame apps.

Thank you! Alex


Solution

  • My own answer after long searching is that Preload FQL results aren't sent to iframe Facebook apps.

    That is why Facebook performance doc says:

    "Preload FQL Query and Multiquery.

    This section applies to FBML canvas pages, but not to websites or IFrame canvas pages."