Skip to content

Instantly share code, notes, and snippets.

@ScottPhillips
Created January 4, 2012 18:11
Show Gist options
  • Save ScottPhillips/1561267 to your computer and use it in GitHub Desktop.
Save ScottPhillips/1561267 to your computer and use it in GitHub Desktop.
Using the PHP SDK to run FQL queries using the Facebook Graph API
<?php
$facebook = new Facebook(array(
'appId' => 'YOUR_API_KEY',
'secret' => 'YOUR_API_SECRET',
'cookie' => true,
));
$fql = "SELECT page_id, name from page where name='Coke'";
$response = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
print_r($response);
?>
<?php
$param = array(
'method' => 'fql.query',
'access_token' => $cookie['access_token'],
'query' => $fql,
'callback' => ''
);
$response = $facebook->api($param);
print_r($response);
?>
@glitz521
Copy link

im looking for a way to write an fql query into php for a website. I have followed the format but unable to get it to work. Im not a programmer so any help is greatly appreciated. Here is what I have:

'My apps id', 'secret' => 'My apps secret', 'cookie' => true, )); $fql = "SELECT name, checkin_count FROM place WHERE page_id = 39875583837"; $response = $facebook->api(array( 'method' => 'fql.query', 'query' =>$fql, )); print_r($response); ?>

When I test the code, I get: Fatal error: Class 'Facebook' not found on line 1

@mickyneo
Copy link

include('facebook.php');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment