Search code examples
facebook-graph-apicountfacebook-likefacebook-fqlphoto

Facebook Graph API and FQL like count on photo's both incorrect?


Hey all,

I've made a facebook application for a contest, which allows users to upload their photo. Once uploaded, the photo gets posted to a dedicated album on their profile. Once the photo is there, the users should collect as many likes as possible.

Currently i have tried both the Facebook Graph API and Facebook FQL to retrieve the amount of likes, but the retrieved likes don't always match the likes on a users profile.

Some users claim to have more then 200 likes, yet the API only returned a maximum of 101 likes so far.


All users are requested to grant the application the following permissions:

user_hometown, publish_stream, read_stream, user_photos and offline_access


Using Facebook PHP SDK 3.0.1 I tried this FQL query to collect the amount of likes of a photo:

  # fql query
  $fql = "SELECT object_id FROM like WHERE object_id=" . $photo_id;

  # api request
  $request = array(
    'method' => 'fql.query', 'query' => $fql
  );

  # run batch request
  $likes = $this->facebook->api($request);

  # return like count
  return count($likes);


I also tried the following Graph API request (Also with Facebook PHP SDK 3.0.1) to collect the amount of likes of a photo:

$likes = $this->facebook->api($photo_id.'/likes');
return count($likes['data']);


Strangely, neither seem to return correct results. I can understand if the API is slightly inaccurate, but according to the API some pictures recieved 100 likes this morning and then 0 likes a few hours later.

Does anyone have any ideas what i might be doing wrong? Do the photo's and their albums need to be public? Do the people who liked the photo need to have a public profile in order to show up in the API? Do i need to request additional permissions?

Any help or suggestions will be greatly appreciated!


Solution

  • Just had the same problem here. The likes seems to be paginated by hundreds by default. Override this setting by using the "LIMIT" query option.