1

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!

  • 1
    Field expansion should be able to help get this data using much less requests. https://developers.facebook.com/docs/graph-api/using-graph-api/#fieldexpansion – CBroe Jul 27 '16 at 06:55
  • @CBroe This will help, let me give it a whirl and I'll let you know how it goes – sjbennett85 Jul 27 '16 at 14:04
  • @CBroe I've tried this and I'm getting the same result. I've looked at the API reference and adapted it to this (maybe it isn't formatted properly) `[post_id]?fields=insights{post_consumptions_by_type}` – sjbennett85 Jul 27 '16 at 15:14
  • 1
    Since insights are requested using `/{object-id}/insights/{metric-name}`, it looks like this syntax doesn't work here. // You could still use batch requests though, so that you can at least reduce the number of HTTP requests necessary. – CBroe Jul 27 '16 at 15:37
  • @CBroe I'll keep drilling away and see if there is any sort of solution I can find for getting multiple metrics off one call. Thanks a bunch! – sjbennett85 Jul 27 '16 at 19:31

1 Answers1

2

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.