I’m trying to use the Facebook graph api for my ad account to get the insights of a specific date. I believe date is the correct parameter to use. Here is Facebook’s documentation for ad account insights https://developers.facebook.com/docs/marketing-api/reference/ad-account/insights/
Here is the url I am attempting to use:
https://graph.facebook.com/v2.6/act_ACCOUNT_ID/insights?access_token=MY_ACCESS_TOKEN&time_range={"since":"2016-08-09","until":"2016-08-09"}&fields=account_id%2Cspend%2Cimpressions%2Ctotal_actions&method=get&pretty=0&sdk=joey
This is the response I get:
{"error":{"message":"(#100) Must be a date representation in the format YYYY-MM-DD","type":"OAuthException","code":100,"fbtrace_id":"HEFP4SeNfWa"}}
4
Answers
I don’t know concerning the single or double quotes. For me, the single quotes worked this way :
However, using Google Apps SCript and UrlFetchApp.fetch method, I had to use encodeURIComponent on the time range parameters to get it to work.
the best way to use this is
You can use this too. This is URL encoded:
time_range=%7B’since’:’2020-04-06′,’until’:’2020-04-09’%7D
but keep in mind that above line only works with the combination of:
time_increment=1