Search the Facebook Graph API using the updated_time parameter

I am using the Facebook Graph API in Python. Each post has two times:

  • created_date
  • updated_date

When I provide the since parameter, it returns channels where created_date greater than or equal to the since parameter. For example, if I provide since=2015-06-05 , then it will return all messages from June 5, 2015 to the present.

But suppose there is a message that was published on June 7, 2015, and several events (like, promotions, comments, etc.) that took place on June 8, 2015. In this case, the updated_time this message changes, but created_time will be the same (June 7, 2015). If I pass the parameter since=2015-06-08 , then I will not be able to track all the activity in this message.

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

+4
source share
1 answer

As @CBroe notes, this is not supported by the Facebook API. (This can be done using FQL , but it is deprecated and will not be supported much longer).

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

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

  • until=2015-07-07 (or whatever since date would be)
  • fields=updated_time (to keep the request fast and a small payload)
  • limit=5000 (or some kind of large page size, since I only captured one field)

Then I evaluate each message with updated_time more than the expected since date, and queues these messages to download the entire contents of the message.

Note. If you are dealing with content where there are frequent updates in past content, most likely you will want to use the Graph API Batch Requests function, as opposed to downloading each message separately.

So, for example, if the until date (and therefore, since ) is 2015-07-07 , and updated_time in the message is 2015-10-15 , then I know that the message was created before 2015-07-07 , but then it is updated. It will not be received in the since request, but I can easily download it separately for cache synchronization.

+7
source

Source: https://habr.com/ru/post/1439389/


All Articles