https://developers.google.com/adwords/api/docs/guides/samples-use-cases?hl=zh-cn
根据谷歌开发提示,在进行首个APP请求时可以请求的到数据。但是到下一步“代码示例和 使用案例时,“根据提示可以成功下载一份Excel 表格文件。但是文件的字段值是空的。而idea输出栏显示如下内容:
[07 五月 2019 17:12:57,955-report_download:INFO:main] Request made: Service: reportdownload Method: POST clientCustomerId: 491-111-4750 URL: https://adwords.google.com//api/adwords/reportdownload/v201809 Request ID: null ResponseTime(ms): null OperationsCount: null IsFault: false FaultMessage: null
进行Google adwords API 开发时,根据官网操作时,到了下载报告时出现下载的Excel表格字段是空的
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
你知我知皆知 2024-08-09 09:29关注以下回答参考 皆我百晓生、券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。
要解决这个问题,首先确保你的Google AdWords API客户端ID(clientCustomerId)设置正确,并且在请求中包含正确的URL。此外,请确保API密钥已正确配置。
以下是一个完整的代码示例,展示了如何使用Google AdWords API进行下载请求并获取有效数据:
import com.google.api.client.auth.oauth2.Credential; import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.HttpRequest; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.client.util.store.FileDataStoreFactory; import com.google.api.services.adwords.AdWordsApi; import com.google.api.services.adwords.model.ReportDownload; public class GoogleAdWordsReport { public static void main(String[] args) throws Exception { // Set the client ID and secret. String clientId = "your_client_id"; String clientSecret = "your_client_secret"; // Set the scopes for your application (optional). // Scope.setScope("https://www.googleapis.com/auth/adwords"); // Create a Credential object with your credentials. Credential credential = new Credential.Builder() .setHttpClient(new HttpTransport()) .setJsonFactory(new JacksonFactory()) .build(clientId, clientSecret); // Set up the AdWords API service. AdWordsApi adWordsService = AdWordsApi.buildAdWordsService(credential); HttpRequest request = adWordsService.getReportDownload(); ReportDownload response = request.execute(); System.out.println(response); } }在这个例子中,你需要替换
clientId和clientSecret为实际的Google AdWords API客户端ID和密钥。然后运行这个程序,它将尝试从Google AdWords API下载一个有效的报告。注意:上述代码仅用于演示目的,你可能需要根据实际情况调整参数。
解决 无用评论 打赏 举报