Today i’m going to talk about the Facebook FQL Methods, how it works and how to fetch the results.
First to use FQL you need to do the following:
require_once 'facebook.php'; $appapikey = 'XXX'; $appsecret = 'XXX'; $facebook = new Facebook($appapikey, $appsecret); $user_id = $facebook->require_login();
So this is the basics of the Facebook Developing now let’s go to the main subject the FQL Query.
What is FQL Query?
In PHP FQL Query-s is class holding normal SQL statements just like this:
api_client->fql_query("SELECT status FROM user WHERE uid='$user_id'"); ?>
The example above shows a FQL class holding normal SQL statements like SELECT and FROM just to select the user status from the databse, The different is the normal SQL query is getting the results from local database, but the FQL query getting the results from the Facebook Main database.
Now you did made a FQL Query but now how to fetch the results?
in the example above we’re trying to get the user status so we can fetch it this way:
api_client->fql_query("SELECT status FROM user WHERE uid='$user_id'"); //FQL Query
//Fetch The results using arrays
$status = $fql[0]['status']['message']; //Getting the actual Status Messaage
$time = $fql[0]['status']['time']; // Getting the status post time in microtime
//Get Status id Using FQL
$id_fql = $facebook->api_client->fql_query("SELECT status_id FROM status WHERE uid= '$user_id'");
$status_id = $id_fql[0]["status_id"];//fetch using arrays again
?>
As you can see we can fetch the results using arrays and we always using array number 0 because array number 1 holding wrong value.
So if you can not understand anything feel free to E-mail me @ m.ahmed@zingyso.com or post comment here and i will reply.
Now see you guys in the next post.
Hi,
I am newbie to facebook developer zone.
Can you please guide me how can I fetch updated status for all public (open) accounts?
Or any other way to fetch status for all users within any date range.
Waiting for reply.
Thanks,
Riti
[Reply]
Good Post
[Reply]