Querying FB Graph API feed with fields parameter?

元气小坏坏 提交于 2020-01-01 19:19:09

问题


what happens when a Facebook page is queried for its feed with Facebook Graph API (JS SDK) and a URL parameter fields (like for the post object) is added?

I would like to load from the feed only the posts id's, shares, likes and comments, because the page is pretty active and the text data in JSON for 2 days is about 2MB (25 items)...

I would hope one could do like this: FB.api('/SomePage?fields=id,shares,likes'), but I suppose the only fields you can access are the direct children (for feed, that is data & paging)? If this unfortunately is the case, is there any other way to retrieve all posts from date x to date y without downloading the entire feed?


回答1:


That's not correct. The feed edge is basically an array of Post objects. You can use the Field Expansion together with time pagination as follows:

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

See

  • 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


来源:https://stackoverflow.com/questions/28436851/querying-fb-graph-api-feed-with-fields-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!