Facebook Graph API搜索使用since_time_time参数 [英] Facebook Graph API search using since updated_time parameter

查看:110
本文介绍了Facebook Graph API搜索使用since_time_time参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Python中使用Facebook Graph API。每个帖子都有两个数据时间:


  1. created_date

  2. updated_date

当我提供参数,它返回的Feed,其中 created_date 大于或等于,因为参数。例如,如果我提供 since = 2015-06-05 ,那么它会将所有帖子从2015年6月5日起返回到现在。



但是假设有一个帖子是在2015年6月7日发布的,并且几乎没有发生在2015年6月8日的活动(喜欢,分享,评论等)。在这种情况下, updated_time 的更改,但 created_time 将是一样的(2015年6月7日)。如果我通过参数 since = 2015-06-08 ,那么我将无法跟踪该帖子上的所有活动。



是否有任何解决方案,我可以通过,因为参数在 updated_time 而不是传递// @ c $ c> created_time

解决方案

正如@CBroe所指出的那样,不受Facebook Graph API的支持。 (可以使用 FQL 完成,但不推荐使用,不会被支持那么说,有一些创造力(和一些额外的代码)可以通过组合几个查询来实现类似的效果。





在我的应用程序中,我使用以下参数执行查询:




  • until = 2015-07-07 (或任何日期以来)

  • fields = updated_time (保持查询速度快,有效载荷小)

  • limit = 5000 / / code>(或一些类似的大页面大小,因为我只是抓住一个字段)



然后我评估每个帖子,自日期起,$ updated_time 大于将要的帖子,并将这些帖子投入队列下载整个帖子内容。


注意:如果您正在处理有关过去内容频繁更新的内容,可能希望将Graph API的批量请求功能用作反对单独下载每个帖子。


所以,例如,如果直到(因此,)日期是 2015-07-07 updated_time 在 2015-10-15 之后,我知道该帖子是在之前创建的2015-07-07 ,但之后更新。 查询之后不会收到,但我可以轻松下载它来同步我的缓存。


I am using the Facebook Graph API in Python. Every post has two datetimes:

  1. created_date
  2. updated_date

When I am providing the since parameter, it is returning feeds where the created_date is greater than or equal to the since parameter. For example, if I provide since=2015-06-05 then it will return all the posts from 5th June, 2015 to now.

But suppose there is a post that was posted on 7th June, 2015 and few activities (likes, shares, comments, etc.) that happened on 8th June, 2015. In this scenario the updated_time of that post changes but created_time will be the same (7th June, 2015). If I pass parameter since=2015-06-08, then I won't be able to track all of the activity on that post.

Is there any solution by which I can pass the since parameter on updated_time instead of passing it to created_time?

解决方案

As @CBroe points out, this isn't supported by the Facebook Graph API. (It can be done using FQL, but that's deprecated and won't be supported for much longer).

That said, with some creativity (and a bit extra code) a similar effect can be achieved by combining a couple of queries.

In my application, I perform a query with the following parameters:

  • until=2015-07-07 (or whatever the since date would have been)
  • fields=updated_time (to keep the query fast and the payload small)
  • limit=5000 (or some similarly large page size, as I'm only grabbing one field)

I then evaluate each post that has an updated_time greater than the would-be since date, and throw those posts into a queue to download the entirety of the post content.

Note: If you're dealing with content where there are frequent updates on past content, you'd likely want to use the Graph API's Batch Requests feature, as opposed to downloading each post individually.

So, for example, if the until (and, thus, since) date is 2015-07-07 and the updated_time on a post is 2015-10-15, then I know that post was created prior to 2015-07-07 but updated afterwards. It won't get picked up in a since query, but I can easily download it individually to synchronize my cache.

这篇关于Facebook Graph API搜索使用since_time_time参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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