[英]Facebook Graph API search using since updated_time parameter
I am using the Facebook Graph API in Python. 我在Python中使用Facebook Graph API。 Every post has two datetimes:
每个帖子都有两个日期时间:
created_date
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. 当我提供
since
参数时,它返回的feed其中created_date
大于或等于since
参数。 For example, if I provide since=2015-06-05
then it will return all the posts from 5th June, 2015 to now. 例如,如果我提供
since=2015-06-05
它将返回从2015年6月5日到现在的所有帖子。
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). 但是假设有一个帖子在2015年6月7日发布,并且在2015年6月8日发生了很少的活动(喜欢,分享,评论等)。在这种情况下,该帖子的
updated_time
发生了变化,但created_time
将是相同的(2015年6月7日)。 If I pass parameter since=2015-06-08
, then I won't be able to track all of the activity on that post. 如果我
since=2015-06-08
传递参数,那么我将无法跟踪该帖子上的所有活动。
Is there any solution by which I can pass the since
parameter on updated_time
instead of passing it to created_time
? 是否有任何解决方案可以通过
updated_time
传递since
参数而不是将其传递给created_time
?
As @CBroe points out, this isn't supported by the Facebook Graph API. 正如@CBroe指出的那样,Facebook Graph API不支持这一点。 (It can be done using FQL , but that's deprecated and won't be supported for much longer).
(它可以使用FQL完成,但是已经弃用,并且不再支持更长时间)。
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) until=2015-07-07
(或者since
任何日期) fields=updated_time
(to keep the query fast and the payload small) fields=updated_time
(保持查询快速,有效负载小) limit=5000
(or some similarly large page size, as I'm only grabbing one field) limit=5000
(或者一些类似的大页面大小,因为我只抓取一个字段) 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. 然后,我评估每个帖子的
updated_time
大于since
日期since
预期,并将这些帖子放入队列以下载整个帖子内容。
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.
注意:如果您正在处理过去内容频繁更新的内容,您可能希望使用Graph API的批量请求功能 ,而不是单独下载每个帖子。
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. 因此,举例来说,如果
until
(并且因此, since
)日期是2015-07-07
并且帖子上的updated_time
是2015-10-15
,那么我知道该帖子是在2015-07-07
之前创建的,但是之后更新。 It won't get picked up in a since
query, but I can easily download it individually to synchronize my cache. 它不会在
since
查询中被提取,但我可以轻松地单独下载它以同步我的缓存。
If the aim of your application is to react to changes on a given page or feed, consider using Webhooks instead of manually crawling the page for updates. 如果您的应用程序的目标是对给定页面或订阅源上的更改做出反应,请考虑使用Webhooks而不是手动抓取页面以进行更新。
Webhooks allows you to receive real-time HTTP notifications of changes to specific objects in the Facebook Social Graph.
Webhooks允许您接收Facebook社交图中特定对象更改的实时HTTP通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.