正在使用字段参数查询FB Graph API提要

Querying FB Graph API feed with fields parameter?

本文关键字:FB Graph API 提要 查询 参数 字段      更新时间:2023-09-26

当使用Facebook Graph API(JS SDK)查询Facebook页面的提要并添加URL参数fields(类似于post对象)时会发生什么?

我想从提要中只加载帖子id、分享、点赞和评论,因为页面非常活跃,JSON中2天的文本数据约为2MB(25项)。。。

我希望可以这样做:FB.api('/SomePage?fields=id,shares,likes'),但我想你唯一可以访问的字段是直接子字段(对于feed,即data&paging)?如果不幸的是,有没有其他方法可以在不下载整个提要的情况下检索从日期x到日期y的所有帖子?

这是不对的。feed边基本上是Post对象的数组。您可以将字段扩展与时间分页一起使用,如下所示:

GET /{page_id}/feed?fields=id,shares,likes.summary(true)&since={start_unix_timestamp}&until={end_unix_timestamp}

参见

  • https://developers.facebook.com/docs/graph-api/reference/v2.2/page/feed/#read
  • https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#fieldexpansion
  • https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging