turtlepower
turtlepower

Reputation: 758

Facebook API Post Impressions Unique (reach)

I'm after the impression uniques for our posts and ideally we would like one server call and it would bring back the last 100 posts with the reach (post_impressions_unique).

To get reach, I can currently do this using:

https://graph.facebook.com/nmemagazine/posts?fields=name,message,full_picture,created_time,shares,likes.limit(1).summary(true),comments.limit(1).summary(true)&access_token=USER_TOKEN

and getting the post ID, then calling: https://graph.facebook.com/v2.5/POST_ID/insights/post_impressions_unique?access_token=USER_TOKEN

Is there a way where I can make one call to get all recent posts and their reach in one API call?

Upvotes: 1

Views: 4804

Answers (2)

mattd
mattd

Reputation: 1

To give an update on this:

In facebook Graph API 2.10, you can (and have to) specify the metrics you are interested in via insights.metric(...). Possible metrics are documented here: https://developers.facebook.com/docs/graph-api/reference/v2.10/insights#availmetrics

For your example:

curl -i -X GET "https://graph.facebook.com/nmemagazine/posts?fields=name,message,full_picture,created_time,shares,likes.limit(1).summary(true),comments.limit(1).summary(true),insights.metric(post_impressions_unique)&access_token=USER_TOKEN"

Upvotes: 0

MartinM
MartinM

Reputation: 1806

You could simply call

https://graph.facebook.com/nmemagazine/posts?fields=name,message,full_picture,created_time,shares,likes.limit(1).summary(true),comments.limit(1).summary(true),insights&access_token=USER_TOKEN

NOTE: extra field "insights".

However, as far as I can tell you cannot limit the insights to just Post_impressions_Unique so it would bring back some data you do not necessarily want/need. I.e. I don't think you can perform a search/filter on a "second level"/child/nested type.

Upvotes: 2

Related Questions