FB Graph API - Tried accessing nonexisting field (reactions) on node type (Photo)

965 Views Asked by At

I am working with FB Graph API to get the names of the users who like or react to my post. By using

get/version/{post-id}/likes

I have been able to get the names and IDs of all likers. Now I also want to get other reactions i.e. HAHA or Love reactions, but when I use get/version/{post-id}/reactions I get this error

{
  "error": {
    "message": "(#100) Tried accessing nonexisting field (reactions) on node type (Photo)",
    "type": "OAuthException",
    "code": 100,
    "fbtrace_id": "Abwl9IBIxglskXT3yivpWUm"
  }
} 

Is it possible to get all reactions or not? The users will authorize the app so that's not a problem.

2

There are 2 best solutions below

0
On BEST ANSWER

So basically after 3 days of wait, I got no answer. So I decided to post an answer myself. What I found in these 3 days is that it is not possible to get all the reactions. Likes and Care are the only data you will get.

If I ever found a way to get it all, I will update the answer.

0
On

It is possible to get all the reactions on a post (including Photos) by requesting this endpoint:

{user_id}_{post_id}?fields=
reactions.type(LOVE).limit(0).summary(total_count).as(love),
reactions.type(WOW).limit(0).summary(total_count).as(wow),
reactions.type(HAHA).limit(0).summary(total_count).as(haha),
reactions.type(LIKE).limit(0).summary(total_count).as(like),
reactions.type(ANGRY).limit(0).summary(total_count).as(angry),
reactions.type(SAD).limit(0).summary(total_count).as(sad)

(Remove all newlines, I put them in only to make the URL more readable).

This returns

{
  "love": {
    "data": [
    ],
    "summary": {
      "total_count": 50
    }
  },
  "wow": {
    "data": [
    ],
    "summary": {
      "total_count": 20
    }
  },
  "haha": {
    "data": [
    ],
    "summary": {
      "total_count": 24
    }
  },
  "like": {
    "data": [
    ],
    "summary": {
      "total_count": 60
    }
  },
  "angry": {
    "data": [
    ],
    "summary": {
      "total_count": 1
    }
  },
  "sad": {
    "data": [
    ],
    "summary": {
      "total_count": 1
    }
  },
  "id": "{user_id}_{post_id}"
}

I got this answer from this post.

It seems that the Facebook API does not support getting reactions on Photos using the shorthand id, but it supports getting reactions using the longhand id, which is {user_id}_{post_id}.