facebook-graph-api - 如何使用 Insights API 异步作业下载 facebook 报告?

标签 facebook-graph-api facebook-ads-api facebook-marketing-api facebook-java-api

您好,我是 Facebook 营销 API 的新手。我想下载 csv 格式的帐户完整报告,我正在使用 Insights API 异步作业,使用它我可以获得“report_run_id”,之后我向 this link 发出 api 请求.它给出了错误的响应。任何人都可以帮助我如何下载 csv 格式的报告。我尝试过的代码是:

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();
}

最佳答案

我将使用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

关于facebook-graph-api - 如何使用 Insights API 异步作业下载 facebook 报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46770268/

相关文章:

php - 错误 "Unable to use the video in an ad creative. Video id XXX,XXX,XXX,XXX,XXX might not be id of a video, or you might not have permission to see it"

facebook-graph-api - Facebook 广告 API : Error 272 This Ads API call requires the user to be admin

ios - iOS 上的 FB 图形 API : FBGraphPlace in FBGraphUser is always nil

facebook - 无法为新创建的相册设置隐私

javascript - FaceBook IFrame 应用程序 : getLoginStatus fails only in Internet Explorer

python - 错误: 'NoneType' object has no attribute 'call'

facebook - 如何在营销 API 中过滤具有特定目标的 Facebook 广告帐户事件?

java - Facebook API 返回的日期值是否采用 GMT 格式?

android - 为什么 FBAudienceNetwork 中的 "(#2) Service Temporarily Unavailable"?

ios - iOS 上的 Facebook 原生广告