解析列表>在安卓中?
根据 javaDocs,AdsenseReportsGenerateResponse.getRows() 生成一个 List>但我有点迷失了如何正确解析它来获取:
-Today's earnings
-Yesterday's earnings
-Last 7 days
-Last month
-From the beginning of time
这是与问题
Reports.Generate request = adsense.reports().generate(startDate, endDate);
request.setMetric(Arrays.asList("PAGE_VIEWS", "AD_REQUESTS", "AD_REQUESTS_COVERAGE", "CLICKS",
"AD_REQUESTS_CTR", "COST_PER_CLICK", "AD_REQUESTS_RPM", "EARNINGS"));
request.setDimension(Arrays.asList("DATE", "WEEK", "MONTH"));
request.setSort(Arrays.asList("+DATE"));
AdsenseReportsGenerateResponse response = request.execute();
//TODO: Here be dragons
response.getRows();
编辑相关的我的代码的一部分:这是提到 getRow()
嗯,这个网站上似乎没有人可以提供帮助?!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该会发现我们的示例代码很有用:http://code .google.com/p/google-api-java-client/wiki/APIs#AdSense_Management_API
也就是说,这是您感兴趣的文件:http://code.google.com/p/google-api-java-client/source/browse/adsense-cmdline-sample/src/main/java/com/google/api/services/ Samples/adsense/cmdline/GenerateReport.java?repo=samples
以下是用于打印输出的代码片段。请注意,这是针对命令行应用程序的,但应该很容易适应:
至于获取不同时间段的数据,您可能应该运行不同的报告,而不是将其全部塞入一个报告中,因为这将需要不同的开始日期和结束日期。其工作原理如下:
这篇博文应该有助于更好地理解报告概念: http://adsenseapi.blogspot.com/2011/11/adsense-management-api-diving-into.html
如果您需要其他帮助,请告诉我!
You should find our sample code useful: http://code.google.com/p/google-api-java-client/wiki/APIs#AdSense_Management_API
Namely, this is the file you're interested in: http://code.google.com/p/google-api-java-client/source/browse/adsense-cmdline-sample/src/main/java/com/google/api/services/samples/adsense/cmdline/GenerateReport.java?repo=samples
Here's a snippet of code to print the output. Mind you, this is for a command line application, but should be easily adaptable:
As for getting the data for different periods of time, you should probably be running different reports, not cramming it all into one, as that would take different start dates and end dates. Here's how it works:
This blog post should help with understanding reporting concepts a bit better: http://adsenseapi.blogspot.com/2011/11/adsense-management-api-diving-into.html
Let me know if you need help with anything else!
据我了解 API,它不是一个
List
。试试这个:据我所知,我写这篇文章是因为 API 说它有一个维度列表,其中一个值用于字符串,一个值用于指标。
如果您期望每行有几个单元格(我相信 API 不能以这种方式工作),您需要在内部添加另一个单元格,并可能使用诸如 array[i].getSize 之类的方法获取当前列表的大小()
如果对您没有帮助,请回帖。
编辑:我现在明白了。试试这个:
Its not a
List<List>
as far as I understand the api. Try this:I am writing this because the API says it has a list of dimensions with one value for the string and one for the metric, as far as I understand.
If you expect several cells on each row (Which I believe the API doesn't work that way), you need to add another for inside and get the size of the current list probably with something like
array[i].getSize()
Post back if it doesn't help you.
Edit: I see now. Try this: