How to get most liked, commented and shared posts from Facebook's API

三世轮回 提交于 2019-12-04 18:12:40
smalu

Yes, you have to make individual API calls. Batch api requests are counted as normal requests [0]:

For example, a batch of 10 API calls will count as 10 calls and each call within the batch contributes to CPU resource limits in the same manner.

My tips:

  • make graph api call server-side and store results in a database
  • make some delays between each call
  • you can increase your request limit by making some delays between each
  • use multiple extended page access tokens [1] and pick random for each call
  • make calls without sdk - you can make simple GET request with eg. curl to https://graph.facebook.com/post_id?access_token=access_token

[0] - https://developers.facebook.com/docs/graph-api/making-multiple-requests/#limits

[1] - https://stackoverflow.com/a/17234650/1587309

You can use FQL (which will be available at least until April 30th 2016) to achieve this in one call:

select post_id, comment_info.comment_count, like_info.like_count, share_info.share_count from stream where source_id={PAGE_ID}

Just replace {PAGE_ID} with the actual Page ID. You can also run this via a Page Access Token with the read_stream permission.

If you want just the Page's posts, add the following to the FQL query:

and actor_id={PAGE_ID}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!