问题
- I am trying to bring comments made on a particular event by targeting this URL:
https://graph.facebook.com/1466384840257158/comments
- I am passing the user_access_token
- I have two comments at present on this event made on the same day(2014-03-29)
- 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
- This request has no effect, it still shows me the two comment made on the 29th
- I have tried the same kind of date range on my user-id/feed and it gave me an empty data object.
- 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.
回答1:
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).
回答2:
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}}
回答3:
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
回答4:
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
来源:https://stackoverflow.com/questions/22732606/facebook-graph-api-event-id-commentssince-2014-02-01until-2014-02-10-date-fi