Question

  1. I am trying to bring comments made on a particular event by targeting this URL: https://graph.facebook.com/1466384840257158/comments
  2. I am passing the user_access_token
  3. I have two comments at present on this event made on the same day(2014-03-29)
  4. Now I try to pass a date which should bring an empty data result/object like this: https://graph.facebook.com/1466384840257158/comments?since=2011-01-01&until=2014-01-10
  5. This request has no effect, it still shows me the two comment made on the 29th
  6. I have tried the same kind of date range on my user-id/feed and it gave me an empty data object.
  7. Finally i tried event-id/feed (before trying date filter) and it gave me the following error

.

{
    "error": {
        "message": "An unexpected error has occurred. Please retry your request later.", 
        "type": "OAuthException", 
        "code": 2
    }
}

Could you please guide me about date filter on that particular query (point4) or if you have any other idea to use date filter on comments made for an event.

Was it helpful?

Solution

Comments use Cursor-based Pagination, so you cannot use since or until on the comments endpoint (these parameters would work f.ex. for the feed endpoint).

To get the comments in a time range you have to fetch all comments from NOW to the start of the time range, f.ex. with https://graph.facebook.com/1466384840257158/comments?filter=stream&limit=1000+paging (the filter=stream will order the result with the timestamp).

OTHER TIPS

USING SINCE UNTIL FOR COMMENTS on GROUP If you want to use since and until for comments, it is not possible directly for a group. So, First you can apply it for status(feed) and then get the comments for that feed. This works for me:

{group_id}/?fields=feed.since(08/25/2016).until(08/31/2016){from,comments{from,message}}

Why don't you try first to filter by notifications?... notifications allows you to add parameters like since. For example (using Facebook pages):

https://graph.facebook.com/PAGEID?fields=notifications.since(2015-3-31 00:00:00).limit(250).include_read(true)&{id,created_time,updated_time,unread,object,link}&access_token=ACCESSTOKEN

Once you got the json data, loop through data, get the ID and send a second request but this time using the PAGEID_POSTID edge. Something like this:

https://graph.facebook.com/PAGEID_POSTID/comments?fields=id,from{name,id},message,can_remove,created_time&limit=1000

Voahla!... there's no need to read every comment!...

Note 1: A Page access token is required, along with the manage_pages permission

Note 2: Use the parameter/field include_read to get all the notifications, even the already readed

Note 3: In the second request, use the parameter/field "filter=stream" to order the posts and get the comments made in the name of your page

Note 4: Don't forget to control the asynchronicity once you loop!

Note 5: Notifications duplicate posts, use an array to avoid to read more than one time the postUse the parameter/field include_read to get all the notifications, even the already readed

I do not know if it's too late. But, Yeah it works in the graph api version 3.3.

for example: if you wanna get comments on a post of a Facebook page you can do it like this:

  • You have to use page Access-token
  • The get Graph Request : post_id/comments?since=some_date
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top