3

Currently I am using following API call to retrieve Post Likes and Post Comments for Facebook Page (PageId). Here in below i am making only one API call and retrieving ALL posts and their comments total count.

1). https://graph.facebook.com/PageId/posts?access_token=xyz&method=GET&format=json

But, as per "July 2013 Breaking Changes" : - Now comments counts are not available with above API call. so , as per Road Map documentation I am using following API call to retrieve comments count ('total_count') for that particular POST ID.

2). https://graph.facebook.com/post_ID/?summary=true&access_token=xyz&method=GET&format=json

So , with second API call - I am able to retrieve comments count per Post Wise. But, here you can see that I need to iterate through each post & need to retrieve its comments count one by one per each post id. then need to sum up all to find out total comments count. so that requires too much API calls.

My Question is :- Is it possible to retrieve Page -> Posts -> ALL comments total count in single API call by considering 10 July breaking changes ?

Is there any alternative to my second API call to retrieve all comments total count per Facebook page posts ?

Spunj Junior
  • 209
  • 1
  • 3
  • 7

1 Answers1

0

Hmm, well, I don't believe there is a way to bundle this all in a single api call. But, you can batch requests to get this in the seemingly same api call (will save time), but they will count against your rate limits separately. (my example below would be 4 calls against the limits)

Example batch call (json encoded) - and i'm storing the post ID in the php variable $postId.:

[{"method":"GET","relative_url":"' . $postId . '"}, 
{"method":"GET","relative_url":"' . $postId . '/likes?limit=1000&summary=true"}, 
{"method":"GET","relative_url":"' . $postId . /comments?filter=stream&limit=1000&summary=true"}, 
{"method":"GET","relative_url":"' . $postId . '/insights"}]

I'm batching 4 queries in this single call. First to get post info, second to get likes (up to 1000, plus the total count), third to get all the comments, plus the summary count, and finlly, insights (if it's the page's own posts).

You can drastically simplify this batch call if you don't want all the details I'm pulling.

In this case you still need to iterate though all. But, Facebook allows you to bundle up to 50 calls per batch request I believe, so you could request multiple post ids in the same batch call to speed things up too.

Chris Drumgoole
  • 332
  • 1
  • 11