Question

fql experts. I've asked this question once before.That was a wrong question so i have got a wrong answer.I didn't know that Facebook-fql and graph-API is same but two other things to query Facebook. This time I am trying to post the right question. How to query Facebook user post likes(not page post) using fql? I have tried-

SELECT+like_info+FROM+stream+WHERE+post_id=488253731301614

Which shows me:

{
 "data": [

 ]
}

I need to change this code to get facebook post like info:

function check_page($id){
    global $facebook;
    try {
        $param = array(
            'method'   => 'fql.query',
            'query'    => "SELECT like_info FROM photo WHERE object_id='".$id."'",
            'callback' => ''
        );
        $response = $facebook->api($param);
        $likes = $response[0]['like_info']['like_count'];
    } catch (FacebookApiException $e) {
        $url = get_data('https://graph.facebook.com/fql?q=SELECT+like_info+FROM+photo+WHERE+object_id='.$id);
        $result = json_decode($url, true);
        $likes = $result['data'][0]['like_info']['like_count'];
    }
    if(is_numeric($likes) && $likes >= 0){
        return true;
    }else{
        return false;
    }
}
Was it helpful?

Solution

Check if following code works.

$param = array(
'method'   => 'fql.query',
'query'    => "SELECT like_info FROM stream WHERE post_id='".$id."'",
'callback' => ''
);
$response = $facebook->api($param);
$likes = $response[0]['like_info']['like_count'];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top