I can query multiple insights metrics like this:
/insights/page_fans,page_fan_adds,page_impressions_unique
but this returns results for 'page_impressions_unique' with all three periods: day, week, days_28
How can I query multiple metrics while one of them has defined period? I tried something likes this:
/insights/page_fans,page_fan_adds,page_impressions_unique/week
The Facebook Insights API will only return values for metrics that satisfy the optional single period given in the call. Since page_fans and page_fan_adds have a period of lifetime, and page_impressions have period day,week,days_28, calling:
/insights/page_fans,page_fan_adds,page_impressions?period=day
Will only result in metrics that are aggregated by day (i.e. page_impressions).
If you want to save on API quota, you may call the API without the period parameter like:
/insights/page_fans,page_fan_adds,page_impressions
and get back lifetime metrics of page_fans,page_fans_adds, and all three periods for page_impressions which you can later parse in your code. The downside to this method is the response is larger and may include information you don't want.
You can also make two API calls instead (one for lifetime metrics, one for day metrics). This option is better when you know you will not hit the API limit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With