Reputation: 657
https://developers.facebook.com/docs/reference/ads-api/adreportstats/
Based on the documentation
time_ranges Array of timestamp objects {time_start, time_stop} or date objects {day, month, year}.
So in the Graph API Explorer, I am setting the time_ranges value as
time_ranges=[{"day_start":{"day":1,"month":11,"year":2013}},{"day_stop":{"day":10,"month":11,"year":2013}}]
This returns me an error
{
"error": {
"message": "(#100) Please set time_start and time_stop or day_start and day_stop.",
"type": "OAuthException",
"code": 100
}
}
I have removed other part of the above URL for brevity. I have tried with date_preset value and the report returns data.
Thanks.
EDIT: The complete URL (sans the valid account id)
https://graph.facebook.com/act_12345/reportstats?data_columns=["account_id","account_name","campaign_id","campaign_name","impressions","clicks","spend"]&time_ranges=["{'day_start':{'day':1,'month':11,'year':2013}}","{'day_stop':{'day':10,'month':11,'year':2013}}"]
Upvotes: 1
Views: 1055
Reputation: 4875
I had the same problem, try using:
time_ranges=["{'day_start':{'day':1,'month':11,'year':2013}, 'day_stop':{'day':10,'month':11,'year':2013}}"]
instead of:
time_ranges=["{'day_start':{'day':1,'month':11,'year':2013}}","{'day_stop':{'day':10,'month':11,'year':2013}}"]
Complete URL:
https://graph.facebook.com/act_12345/reportstats?data_columns=["account_id","account_name","campaign_id","campaign_name","impressions","clicks","spend"]&time_ranges=["{'day_start':{'day':1,'month':11,'year':2013}, 'day_stop':{'day':10,'month':11,'year':2013}}"]
I opened a documentation issue at https://developers.facebook.com/x/bugs/1423346704577387/
Upvotes: 0
Reputation: 41
I had (have!) an identical issue.
I worked around it by using time_start
and time_stop
instead of day_start
and day_stop
. Stupid, I know... but it's what worked for me.
So to get 1-day's worth of data (the 19th of Nov for example):
&time_ranges=["{'time_start': '2013-11-19','time_stop':'2013-11-20'}"]
Upvotes: 4
Reputation: 2800
Oddly enough, the example appears to be an array of strings that are json objects. So try changing this line:
time_ranges=[{"day_start":{"day":1,"month":11,"year":2013}},{"day_stop":{"day":10,"month":11,"year":2013}}]
to this:
time_ranges=["{'day_start':{'day':1,'month':11,'year':2013}}","{'day_stop':{'day':10,'month':11,'year':2013}}"]
Upvotes: 0