Facebook Graph API 搜索使用自更新时间参数 [英] Facebook Graph API search using since updated_time parameter

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

问题描述

我在 Python 中使用 Facebook Graph API.每个帖子都有两个日期时间:

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

  1. created_date
  2. updated_date

当我提供 since 参数时,它返回 created_date 大于或等于 since 参数的提要.例如,如果我提供 since=2015-06-05 那么它将返回从 2015 年 6 月 5 日到现在的所有帖子.

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.

但是假设有一个帖子是在 2015 年 6 月 7 日发布的,而在 2015 年 6 月 8 日发生的活动很少(喜欢、分享、评论等).在这种情况下,updated_time该帖子的更改但 created_time 将相同(2015 年 6 月 7 日).如果我传递参数 since=2015-06-08,那么我将无法跟踪该帖子上的所有活动.

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.

有什么解决方案可以让我在 updated_time 上传递 since 参数而不是将它传递给 created_time?

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

推荐答案

As @CBroe 在评论中指出,Facebook Graph API 不支持此功能.(之前使用 Facebook 查询语言 (FQL) 支持它,但现在不再可用).

As @CBroe points out in the comments, this isn't supported by the Facebook Graph API. (It was previously supported using Facebook Query Language (FQL), but that's no longer available).

也就是说,通过一些创意(和一些额外的代码),可以通过组合几个查询来实现类似的效果.

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(或任何 since 日期)
  • fields=updated_time(保持查询速度快,负载小)
  • limit=5000(或一些类似的大页面尺寸,因为我只抓取一个字段)
  • 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)

然后我评估每个帖子的 updated_time 大于预期的 since 日期,并将这些帖子放入队列以下载整个帖子内容.

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.

因此,例如,如果 until(因此,since)日期是 2015-07-07updated_time 在单个帖子上是 2015-10-15,那么我知道该帖子是在 2015-07-07 之前创建代码>但之后更新.它不会在 since 查询中被获取,但我可以轻松地单独下载它以同步我的缓存.

So, for example, if the until (and, thus, since) date is 2015-07-07 but the updated_time on an individual 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.

注意:如果您正在处理对过去内容进行频繁更新的内容,您可能希望使用 Graph API 的 批量请求功能,而不是单独下载每个帖子.

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.

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

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