Reputation: 21
I am trying to use Facebook's graph API to access every post in a group's feed, along with the number of reactions of each type, for every post.
When I try with just one reaction type, it works fine:
[GROUP_ID]/feed/?fields=message,from,created_time,updated_time,reactions.type(LOVE).limit(0).summary(total_count)&limit=1
However, when I add multiple reaction types, I receive an error.
[GROUP_ID]/feed?fields=message,from,created_time,updated_time,reactions.type(LOVE).limit(0).summary(total_count),reactions.type(WOW).limit(0).summary(total_count)&limit=1
gives me:
{
"error": {
"message": "Syntax error \"Field reactions specified more than once. This is only possible before version 2.1\" at character 139: message,from,created_time,updated_time,reactions.type(LOVE).limit(0).summary(total_count),reactions.type(WOW).limit(0).summary(total_count)",
"type": "OAuthException",
"code": 2500,
"fbtrace_id": "GzMCG2dRioK"
}
}
I followed the syntax in this post, however it seems to only work when trying to access reactions for a single post, not for every post in a feed. Is the only option to use the API to grab the post ID's for every post in the feed, and then make individual calls on every post?
Upvotes: 2
Views: 2372
Reputation:
You can get around the aliasing issue, and still receive what you need, by asking for the following:
insights.metric(post_reactions_by_type_total).period(lifetime)
(I found it here: Getting Facebook Post all Reactions Count in single Graph API request)
Upvotes: 1
Reputation: 1462
Try this:
[GROUP_ID]/feed?fields=message,from,created_time,updated_time
,reactions.type(LOVE).limit(0).summary(total_count).as(reactions_love)
,reactions.type(WOW).limit(0).summary(total_count).as(reactions_wow)
&limit=1
Then you find instead of reactions
the fields reactions_love
and reactions_wow
with your desired data. You can add all types and it is shortened here for a better overview ;)
Upvotes: 3