【发布时间】:2021-08-31 11:56:10
【问题描述】:
虽然 migrating 来自旧版本,但我在提取报告时遇到了问题。
来自 v1.4 的相同报告在 v2 中不返回任何数据:
v1.4 报告抓取:
self.service.accounts().reports().generate(
accountId=account_id, startDate=start_date.strftime(self.DATE_FORMAT),
endDate=end_date.strftime(self.DATE_FORMAT),
metric=metrics, dimension=dimensions).execute()
回复:
{u'averages': ...,
u'endDate': u'2021-06-13',
u'headers': [{u'name': u'DATE', u'type': u'DIMENSION'},
{u'name': u'APP_NAME', u'type': u'DIMENSION'},
{u'name': u'APP_ID', u'type': u'DIMENSION'},
{u'name': u'APP_PLATFORM', u'type': u'DIMENSION'},
{u'name': u'BID_TYPE_CODE', u'type': u'DIMENSION'},
{u'name': u'PRODUCT_NAME', u'type': u'DIMENSION'},
{u'name': u'COUNTRY_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_CODE', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_SIZE_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_SIZE_CODE', u'type': u'DIMENSION'},
{u'name': u'REACHED_AD_REQUESTS', u'type': u'METRIC_TALLY'},
{u'name': u'CLICKS', u'type': u'METRIC_TALLY'},
{u'currency': u'USD', u'name': u'EARNINGS', u'type': u'METRIC_CURRENCY'},
{u'name': u'VIEWED_IMPRESSIONS', u'type': u'METRIC_TALLY'},
{u'name': u'MATCHED_REACHED_AD_REQUESTS', u'type': u'METRIC_TALLY'}],
u'kind': u'adsense#report',
u'rows': ...
u'startDate': u'2021-06-13',
u'totalMatchedRows': u'10069',
u'totals': ...,
u'warnings': [u'Some of the requested ad clients do not support the requested combination of dimensions.',
u'Some of the requested ad clients do not support the requested combination of dimensions.']}
v2 报告抓取:
self.service.accounts().reports().generate(
account='accounts/' + account_id, dateRange="CUSTOM",
startDate_year=start_date.year, startDate_month=start_date.month, startDate_day=start_date.day,
endDate_year=end_date.year, endDate_month=end_date.month, endDate_day=end_date.day,
metrics=metrics, dimensions=dimensions).execute()
回复:
{u'endDate': {u'day': 13, u'month': 6, u'year': 2021},
u'headers': [{u'name': u'DATE', u'type': u'DIMENSION'},
{u'name': u'PRODUCT_NAME', u'type': u'DIMENSION'},
{u'name': u'PLATFORM_TYPE_NAME', u'type': u'DIMENSION'},
{u'name': u'BID_TYPE_CODE', u'type': u'DIMENSION'},
{u'name': u'COUNTRY_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_ID', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_SIZE_NAME', u'type': u'DIMENSION'},
{u'name': u'AD_UNIT_SIZE_CODE', u'type': u'DIMENSION'},
{u'name': u'AD_REQUESTS', u'type': u'METRIC_TALLY'},
{u'name': u'CLICKS', u'type': u'METRIC_TALLY'},
{u'currencyCode': u'USD',
u'name': u'TOTAL_EARNINGS',
u'type': u'METRIC_CURRENCY'},
{u'name': u'TOTAL_IMPRESSIONS', u'type': u'METRIC_TALLY'},
{u'name': u'MATCHED_AD_REQUESTS', u'type': u'METRIC_TALLY'}],
u'startDate': {u'day': 13, u'month': 6, u'year': 2021},
u'warnings': [u'Some of the requested dimensions (or their combination) do not apply to some of the ad clients used by this report.',
u'Some of the requested metrics are not available for some of the ad clients used by this report.']}
还检查了python example,但一切都一样。
如果需要,将私下发送 account_id。
*为 AdSense 管理 API 使用 python 包(googleapiclient、oauth2client)。
谢谢
【问题讨论】:
标签: report adsense adsense-api migrating