获取评论:
post_ID/comments?limit=1000&filter=stream&summary=1
当评论有多页或者需要获取评论更新时,使用after:
post_ID/comments?limit=100&filter=stream&summary=1&after=……
最终返回的结果类似于:
{
"data": [
{
"id": "10152781915167405_10152784024147405",
"from": {
"id": "1379887295667365",
"name": "Snow John"
},
"message": "很美,加油",
"can_remove": true,
"created_time": "2015-04-14T01:11:08+0000",
"like_count": 0,
"user_likes": false
}
],
"paging": {
"cursors": {
"after": "WTI5dGJXVnVkRjlqZFhKemIzSTZNVEF4TlRJM09EUXdNalF4TkRjME1EVTZNVFF5T0RrM016ZzJPQT09",
"before": "WTI5dGJXVnVkRjlqZFhKemIzSTZNVEF4TlRJM09EUXdNalF4TkRjME1EVTZNVFF5T0RrM016ZzJPQT09"
},
"previous": "https://graph.facebook.com/v2.2/232716627404_10152781915167405/comments?limit=100&filter=stream&summary=1&before=WTI5dGJXVnVkRjlqZFhKemIzSTZNVEF4TlRJM09EUXdNalF4TkRjME1EVTZNVFF5T0RrM016ZzJPQT09"
},
"summary": {
"order": "chronological",
"total_count": 184
}
}
链接里summary=1表示给出汇总结果,在返回的json数据中会有“summary”,其中“order”代表了排序类型,为枚举格式,取值为{chronological,ranked};
-chronological:按照时间排序;
- ranked:the most interesting comments are sorted first;
返回结果的排序类型与参数“filter”有关,filter有两种取值,toplevel 和stream
- toplevel:默认取值,返回所有的直接评论(toplevel comments),排序方式可以为chronological或者ranked,根据Facebook的排序方式而定。(toplevel - this is the default, returns all top-level comments in either ranked or chronological order depending on how the comments are ordered on Facebook.)
- stream:返回所有的评论,包括comments以及reply,排序方式为chronological
filter参数的取值造成了”total_count”的数量不同,为toplevel时返回的仅是直接评论的数量,为stream时,返回的是所有评论和回复的数量。
点赞和评论类似,使用分页方式获取点赞时链接地址为:
post_ID/likes?limit=100&filter=stream&summary=1&after=……