问题
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