FacebookRestClient::fql_query PHP Method

fql_query() public method

Makes an FQL query. This is a generalized way of accessing all the data in the API, as an alternative to most of the other method calls. More info at http://developers.facebook.com/documentation.php?v=1.0&doc=fql
public fql_query ( string $query ) : generalized
$query string the query to evaluate
return generalized array representing the results
    public function fql_query($query)
    {
        return $this->call_method('facebook.fql.query', array('query' => $query));
    }

Usage Example

Example #1
0
<?php

require_once 'facebook-client/facebook.php';
require_once 'facebook-client/facebookapi_php5_restlib.php';
$appapikey = '{YOUR API KEY HERE}';
$appsecret = '{YOUR APPLICATION SECRET KEY HERE}';
// do this after validation
$userid = $_REQUEST['fb_sig_user'];
$sKey = $_REQUEST['fb_sig_session_key'];
if ($_REQUEST['action'] == "getName") {
    try {
        $fbClient = new FacebookRestClient($appapikey, $appsecret, $sKey);
    } catch (FacebookRestClientException $ex) {
        // Handle Exception
    }
    $userInfo = $fbClient->fql_query("SELECT name FROM user WHERE uid={$userid}");
    $userName = $userInfo[0]['name'];
    // $userName now contains user's name.
}