【发布时间】:2016-02-22 00:06:27
【问题描述】:
我对 Google Apps 脚本还很陌生。我正在使用 Google 的功能通过应用脚本访问 DFA/DCM Trafficking and Reporting API,而无需使用 OAuth。
当我运行 DCM 报告然后将其转换为 google 表格时,我无法弄清楚如何使用我提供的任一 URL 来下载 CSV。
这是我正在使用的代码。
var file = DCM.Reports.run(profile.profileId,30792432);
var file2 = DCM.Files.get(30792432, file.id);
//wait till running of the report is complete.
file2 = DCM.Files.get(30792432, file.id);
var response = UrlFetchApp.fetch(file2.urls.browserUrl);
我也尝试使用:
file2.urls.apiUrl();
对于UrlFetchApp 服务,但这也不起作用。
任何有关如何执行 url 以将文件下载为对象的帮助,我都可以粘贴到谷歌表格中。
【问题讨论】:
-
你得到什么回应?
Logger.log(response)的输出是什么? -
HTTP,我已将其复制到此 word 文档中。 docs.google.com/document/d/…
-
您的word文档中的html代码不完整。那里没有实际的dcm数据。你确定你复制了整个东西吗?
-
我刚刚将完整的数据集导出到 word doc 中,您可以看到,现在它已经完成了。你可以再检查一下。没有 DCM 数据,(据我所知)。我能得到的最接近的是 BrowserURL,它为我提供了一个下载 csv 文件的窗口。我会分享网址,但它包含一些敏感信息。
-
apiUrl怎么样?这会给你任何数据吗?
标签: google-apps-script google-sheets-api google-reporting-trafficking-api