Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I execute a FQL query with Facebook Graph API

I'm looking without any success for a way to execute a FQL(facebook query language) query with the new Open Graph API.

Does anyone know how I can do this?

Found the answer here with this excellent example: http://code.google.com/p/facebook-cpp-graph-api/

like image 798
user63898 Avatar asked Apr 27 '10 14:04

user63898


People also ask

How does Facebook Graph API work?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.


2 Answers

Here's an example of how to do a FQL query using the Graph API and JavaScript

FB.api(         {             method: 'fql.query',             query: 'SELECT uid, first_name, last_name FROM user WHERE uid = ' + someUid         },         function(data) {             //    do something with the response         } ); 

This assumes you've already setup your page according to the Facebook guidelines as shown here - http://developers.facebook.com/docs/reference/javascript/

like image 103
mjallday Avatar answered Sep 19 '22 20:09

mjallday


PHP Solution:

$data = $facebook->api(array('method' => 'fql.query', 'query' => 'SELECT columns FROM table...' )); 
like image 38
Ilya Vassilevsky Avatar answered Sep 19 '22 20:09

Ilya Vassilevsky