How to fetch facebook reactions for posts

Facebook reactions were introduced by Facebook last year. Prior to that you could only like Facebook posts. But after introductions of reactions, you react to a given post in 6 different ways. Fetching likes for facebook posts is simple. But how to fetch various facebook reactions for Facebook posts?

So here is the simple code. It makes use of restfb java client and assumes you already would have got the access token and facebook client for the user

JsonObject reactions = client.fetchObject("v2.6/" + id,JsonObject.class,
			Parameter.with("fields",
											"reactions.type(LOVE).limit(0).summary(total_count).as(reactions_love),
reactions.type(WOW).limit(0).summary(total_count).as(reactions_wow),
reactions.type(HAHA).limit(0).summary(total_count).as(reactions_haha),
reactions.type(LIKE).limit(0).summary(total_count).as(reactions_like),
reactions.type(ANGRY).limit(0).summary(total_count).as(reactions_angry),
reactions.type(SAD).limit(0).summary(total_count).as(reactions_sad)"));

Here ‘id’ is the facebook object ID of the post who reactions you want to fetch

Uday Ogra

Connect with me at http://facebook.com/tendulkarogra and lets have some healthy discussion :)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *