【问题标题】:Adwords API report optionsAdwords API 报告选项
【发布时间】:2015-08-03 20:31:00
【问题描述】:

我正在研究 Adwords API,但无法找到如何在下载后不解析报告的情况下获取报告。

我花费了大量时间,但在日期之间获取关键字数据的唯一真正选择是使用报告,但看起来您必须下载然后解析它们,对吗?

提前致谢

【问题讨论】:

    标签: java google-ads-api


    【解决方案1】:

    将下载格式设置为 csv,这样您将获得 CSV 格式的输出文件。

    ReportDefinition reportDefinition = new ReportDefinition();
    reportDefinition.setReportName("Criteria performance report #" + System.currentTimeMillis());
    reportDefinition.setDateRangeType(ReportDefinitionDateRangeType.YESTERDAY);
    reportDefinition.setReportType(ReportDefinitionReportType.CRITERIA_PERFORMANCE_REPORT);
    reportDefinition.setDownloadFormat(DownloadFormat.CSV);
    
    ReportDownloadResponse response =
          new ReportDownloader(session).downloadReport(reportDefinition);
      response.saveToFile(reportFileName);
    

    【讨论】:

      【解决方案2】:

      如果有人仍然对解决方案感兴趣,我可能还不够清楚,我的目标是在不下载文件的情况下获取日期,我想作为一个对象获取并插入到本地数据库中。

      最后我得到了 xml 格式并使用了 XPATH 或类似的东西。

      我还没有找到将响应报告作为对象获取的方法。

      【讨论】:

        【解决方案3】:

        我很确定没有办法以真正的“API”方式访问报告,您基本上无法解析 CSV。不过,一个技巧是,现在您至少可以将响应作为字符串获取,而不是从本地文件系统写入/读取:

                        $response = $reportDownloadResult->getAsString();
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多