skip to Main Content

Using PHP, i can retrieve the images from a facebook page using a URL like this:

https://graph.facebook.com/v2.7/albumid/photos?access_token=XXXXXXX&debug=all&fields=images&format=json&method=get&pretty=1&suppress_http_code=1

But how can i get the likes count for each photos ? The URL above only returns image url, width and height. I’m looking for the number of likes for each page photos (not user photos)

2

Answers


  1. From you API you will get photo ID of each photo you have to use that Photo ID .

    TRY this ,

    /* PHP SDK v5.0.0 */
    /* make the API call */
    $request = new FacebookRequest(
      $session,
      'GET',
      '/{photo-id}/likes'
    );
    $response = $request->execute();
    $graphObject = $response->getGraphObject();
    /* handle the result */
    

    OR

    GET /v2.8/{photo-id}/likes HTTP/1.1
    

    For more information check this link

    Login or Signup to reply.
  2. But how can i get the likes count for each photos ?

    By requesting the relevant field, same as you are already doing with images:

    /albumd-id/photos?fields=images,likes
    

    That will give you the individual likes. Since you are not interested in those, but only the total count, add summary=1 and a limit of 0, which using field expansion syntax would look like this:

    /albumd-id/photos?fields=images,likes.summary(1).limit(0)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search