0

嗨,我是新的facebook營銷API。我想以csv格式下載我正在使用Insights API異步作業的帳戶完整報告,使用它可以獲得「report_run_id」,然後我提出了對this link的api請求。它給出了錯誤的響應。任何人可以幫助我如何可以下載CSV format.code報告,我想的是:如何使用Insights API異步作業下載Facebook報告?

OkHttpClient client = new OkHttpClient();  
Request request = new Request.Builder() 
    .url("https://www.facebook.com/ads/ads_insights/export_report/?report_run_id=279445242544715&name=reports&format=csv") 
    .get() 
    .build(); 

Response response = client.newCall(request).execute(); 
if(response.isSuccessful()){ 
String resposes=response.body().string(); 
} 

回答

1

我會給使用curl例子,但是你應該能夠很容易地這些轉換爲JavaScript。

使用report_run_id,您可以查詢異步查詢的完整性,例如:

curl -G \ 
    -d 'access_token=<ACCESS_TOKEN>' \ 
    https://graph.facebook.com/v2.10/1000002 

這最終應該給你100%的完成:

{ 
    "id": "6044775548468", 
    "account_id": "1010035716096012", 
    "time_ref": 1459788928, 
    "time_completed": 1459788990, 
    "async_status": "Job Completed", 
    "async_percent_completion": 100 
} 

然後,您需要通過洞察力邊緣查詢report_run_id:

curl -G \ 
    -d 'access_token=<ACCESS_TOKEN>' \ 
    https://graph.facebook.com/v2.10/<YOUR_REPORT_RUN_ID>/insights