I'm currently grabbing post-level insights from my FB page 2.5 for a dashboard to see how well recent posts are doing; a simple benchmark/performance manager dashboard that does all the querying on the front-end [js api].
The calls/procedure I used to use:
1) Get my posts
[page_id]/posts
2) Then loop them and pull the post data from two synchronous calls
// A) gets all the metrics
[page_post_id]/insights
// B) gets other data critical for front-end display
[page_post_id]/?fields=type,created_time,permalink_url
This works perfectly, and for as far as FB says, it will work until June 2018 (I think).
My problem is that the call for step 2-A fails because I believe it requires a separate call for each metric.
That 2-A call returns:
{
"error": {
"message": "Invalid query",
"type": "OAuthException",
"code": 3001,
"error_subcode": 1504028,
"is_transient": false,
"error_user_title": "No Metric Specified",
"error_user_msg": "No metric was specified to be fetched. Please specify one or more metrics to be fetched and try again.",
"fbtrace_id": "XXXXXXXXX"
}
}
Am I wrong?
Is there something that could be done better or would I need to call each metric independently?
I'll eventually need to get there in 2 years but better to address it early and get my teeth on that fresh, new data.
Thanks in advance everyone!
Cheers!
I used a similar setup in Python and ran into the same issue.I've discovered that the {metric} parameter can actually be an array of values.
In Facebook's Graph Explorer I managed to get multiple metrics in one call using this syntax:
<post_id>/insights/["post_stories","post_storytellers"]
You can add additional metrics to the array as needed.
As far as I can tell this feature is not (properly) documented in the Graph API documentation pages, so I'm not sure this usage is intended or not.