Fql.query

From Facebook Developer Wiki (FbDevWiki.com)
Jump to: navigation, search

Please refer to the FQL pages for details on the syntax for an FQL query.

JavaScript SDK example: (Also see FB.Data.query about doing a query asynchronously)

// UNTESTED EXAMPLE
FB.api(
  {
    method: 'fql.query',
    query: 'SELECT uid2 FROM friend WHERE uid1=me() LIMIT 10'
  },
  function(response) {
    // do something with response...
  }
);


PHP SDK example:

// this example assumes the user already gave permission and there's a valid session
require './facebook.php';
 
$facebook = new Facebook(array(
  'appId'  => 'YOUR APP ID',
  'secret' => 'YOUR API SECRET',
  'cookie' => true, // enable optional cookie support
));
 
$session = $facebook->getSession();
if ($session) {
  try {
     $some_friends = $facebook->api(array(
          'method' => 'fql.query',
          'query' => 'SELECT uid2 FROM friend WHERE uid1='.$facebook->getUser().' LIMIT 10'
        ));
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}
Personal tools
Namespaces
Variants
Actions
Navigation
Graph API
FQL
Toolbox