Facebook Api - Albums/Photos/Comments

349 views Asked by At

I wonder if anybody knows an option for what I am currently having an issue with while using the facebook API. I am happy to use either the graph api or fql to get around this problem in the short term, I am already using both at the moment, with plans to look at realtime subscriptions before fql deprecates.

I am currently checking periodically for updates to a page, this includes comments that are on any post, photo, album, video etc.

Using fql this is simple enough for the main stream as the main post object contains an updated_time field, this updates when comments are made against it. I can then filter on that and get posts with new comments, with a second query in the batch to get the comment objects since that time. This gives me only what I need which can be processed quickly and facebook are happy because the processing time is very low. For the record, something like this works fine in a batch:

SELECT post_id, actor_id, created_time, updated_time, message 
FROM stream 
WHERE source_id = me() AND updated_time > 1433783133
SELECT id, time, post_id, fromid, text 
FROM comment 
WHERE post_id IN (SELECT post_id FROM #posts) AND time > 1433783133

However this becomes a real problem when looking at albums, the photos in those albums and comments on those albums. This is what I have looked at and found:

Graph Api

Looking at the graph api, you can't really get hold of the comments without looking at each post and using since - there is an updated_time field against both the album and the photos, however this does not seem to update with anything worthwhile enough to be used in this case.

Example using a nested query:

me/albums?fields=id,created_time,updated_time,photos{id,created_time,updated_time,comments{created_time}}

{
  "updated_time": "2015-05-26T19:12:18+0000", 
  "photos": {
    "data": [
      {
        "updated_time": "2015-05-26T19:12:13+0000", 
        "comments": {
          "data": [
            {
              "created_time": "2015-05-31T19:10:41+0000", 
            }
          ],
        }
      }
    ]
  }
}

You can see the comment has a created_time of the 31st, but the updated_time of the parents both are not inline with this (other updates set those values, but not comments like they do in fql for the stream.)

Another downside of this angle, is that querying the updated time of the parents, will still give me too many children and is less efficient.

Fql

Using Fql is near impossible to get this data correctly also, the modified field has the same issue as the graph api updated_time. I was hoping there may be an option to get all comments at the album level then filer on that and work my way up, but there is no viable indexed field to query on to do so. It has to be by photo, when there is a huge number of albums and photos, this quickly becomes a problem when batching from album > photo > comment as it's very slow to go through this data looking for updates.

This is currently an issue I cannot see a way around with the current api, I haven't dug into the realtime subscriptions yet, but I don't see a relevant subscription for a page for this anyway?

Has anyone had a similar issue getting only updates from the api for a page photos? If so did you find a way around this problem? Because I'm fairly stumped.

Appreciate anyone's time reading that :)

0

There are 0 answers