如何从Facebook的API获得最受欢迎,评论和分享的帖子 [英] How to get most liked, commented and shared posts from Facebook's API

查看:298
本文介绍了如何从Facebook的API获得最受欢迎,评论和分享的帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Facebook获取一些数字,告诉我哪些帖子对于给定的Facebook页面以及在给定的日期范围内具有最多的喜好,评论和共享。



如果我查询API来获取所有的个人帖子并在自己的代码中循环使用,我可以得到这些数字,但是我经常从因为我正在打电话给每个帖子,API600个电话每600秒的速率限制错误。我已经尝试使用FB的批量图请求,但这并没有减少获得该错误的可能性。



有没有办法这样做,所以我不需要打这么多电话?

解决方案

是的,你必须进行单独的API调用。批处理api请求被视为正常请求[0]:


例如,一批10个API调用将计为10个调用,每个批处理中的调用以同样的方式贡献CPU资源限制。


我的提示:




  • 使图api调用服务器端并将结果存储在数据库中

  • 在每次调用之间发生一些延迟

  • 您可以通过在每个

  • 使用多个扩展页面访问令牌[1]之间造成一些延迟,并为每个通话选择随机选项来增加您的请求限制

  • 在没有sdk的情况下拨打电话 - 您可以使用例如简单的GET请求。卷曲到 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


I'm trying to get some figures from Facebook telling me which posts have the most likes, comments and shares for a given Facebook page and within a given date range.

I can get these figures if I query the API to get all the individual posts and loop through them in my own code, but I'm often getting an error from the API "600 calls per 600 seconds" rate limit error from them, because I'm making a call for each post. I've tried using FB's batch graph requests but this doesn't reduce the likelyhood of getting that error.

Is there a way to do this so that I don't need to make so many calls?

解决方案

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

这篇关于如何从Facebook的API获得最受欢迎,评论和分享的帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆