Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook Graph API and FQL like count on photo's both incorrect?
    text
    copied!<p>Hey all,</p> <p>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.</p> <p>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.</p> <p>Some users claim to have more then 200 likes, yet the API only returned a maximum of 101 likes so far.</p> <p><br /></p> <p>All users are requested to grant the application the following permissions:</p> <pre><code>user_hometown, publish_stream, read_stream, user_photos and offline_access </code></pre> <p><br /></p> <p>Using Facebook PHP SDK 3.0.1 I tried this FQL query to collect the amount of likes of a photo:</p> <pre><code> # fql query $fql = "SELECT object_id FROM like WHERE object_id=" . $photo_id; # api request $request = array( 'method' =&gt; 'fql.query', 'query' =&gt; $fql ); # run batch request $likes = $this-&gt;facebook-&gt;api($request); # return like count return count($likes); </code></pre> <p><br /></p> <p>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:</p> <pre><code>$likes = $this-&gt;facebook-&gt;api($photo_id.'/likes'); return count($likes['data']); </code></pre> <p><br /></p> <p>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.</p> <p>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?</p> <p>Any help or suggestions will be greatly appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload