Reputation: 540
Note: this is an updated post
In Facebook I have scheduled report reports to be sent to my e-mail. Unfortunately reports are not coming as attachment but rather as a link e.g. below https://www.facebook.com/ads/manage/download_report.php?act=1119884838046520&report_run_id=6086936413420&format=csv&source=email_v2
Please help me to construct the URI path to retrieve the report.
Current state
I am able to get properties of the report:
RCurl::getURL("https://graph.facebook.com/v2.9/6087139848020?access_token=EAAX****")
results into
$ id : chr "6087139848020"
$ account_id : chr "1119884838046520"
$ schedule_id : chr "6085730147820"
$ time_ref : num 1.49e+09
$ time_completed : num 1.49e+09
$ async_status : chr "Job Completed"
$ async_percent_completion: num 100
$ friendly_name : chr "*****"
$ date_start : chr "2017-05-03"
$ date_stop : chr "2017-05-03"
So everything seems OK
Problem
However by trying to access the /report_ID/insights
as suggested FB API reference/ad-report-run/:
RCurl::getURL("https://graph.facebook.com/v2.9/6087139848020/insights?access_token=E***")
I get an error message:
(#100) Tried accessing nonexisting summary field (results)
Any ideas how to get the body of Facebook report distributed by e-mail?
Help will be strongly appreciated.
PS Special thanks to user @phwd for suggestions
Upvotes: 0
Views: 156
Reputation: 540
The solution is
curl -G \
-d 'report_run_id=6087450841820' \
-d 'format=csv' \
'https://www.facebook.com/ads/ads_insights/export_report/'
Source of info: FB docs for asynchronous reports
Upvotes: 1