I am using the Facebook Graph API in Python. 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. 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.
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 allows you to receive real-time HTTP notifications of changes to specific objects in the Facebook Social Graph.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.