在 AdSense v2 中接收报告数据

问题描述

虽然 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()

获取https://www.googleapis.com/adsense/v1.4/accounts/pub-***/reports?startDate=2021-06-13&metric=REACHED_AD_REQUESTS&metric=CLICKS&metric=EARNINGS&metric=VIEWED_IMPRESSIONS&metric=MATCHED_REACHED_AD_REQUESTS&endDate=2021-06-13&dimension=DATE&dimension=APP_NAME&dimension=APP_ID&dimension=APP_PLATFORM&dimension=BID_TYPE_CODE&dimension=PRODUCT_NAME&dimension=COUNTRY_NAME&dimension=AD_UNIT_CODE&dimension=AD_UNIT_NAME&dimension=AD_UNIT_SIZE_NAME&dimension=AD_UNIT_SIZE_CODE&dimension=REACHED_AD_REQUESTS&alt=json

回复:

{u'averages': ...,u'endDate': u'2021-06-13',u'headers': [{u'name': u'DATE',u'type': u'DIMENSION'},{u'name': u'APP_NAME',{u'name': u'APP_ID',{u'name': u'APP_PLATFORM',{u'name': u'BID_TYPE_CODE',{u'name': u'PRODUCT_NAME',{u'name': u'COUNTRY_NAME',{u'name': u'AD_UNIT_CODE',{u'name': u'AD_UNIT_NAME',{u'name': u'AD_UNIT_SIZE_NAME',{u'name': u'AD_UNIT_SIZE_CODE',{u'name': u'REACHED_AD_REQUESTS',u'type': u'METRIC_TALLY'},{u'name': u'CLICKS',{u'currency': u'USD',u'name': u'EARNINGS',u'type': u'METRIC_CURRENCY'},{u'name': u'VIEWED_IMPRESSIONS',{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()

获取https://adsense.googleapis.com/v2/accounts/pub-***/reports:generate?startDate.month=6&endDate.day=13&dimensions=DATE&dimensions=PRODUCT_NAME&dimensions=PLATFORM_TYPE_NAME&dimensions=BID_TYPE_CODE&dimensions=COUNTRY_NAME&dimensions=AD_UNIT_ID&dimensions=AD_UNIT_NAME&dimensions=AD_UNIT_SIZE_NAME&dimensions=AD_UNIT_SIZE_CODE&endDate.month=6&startDate.year=2021&startDate.day=13&metrics=AD_REQUESTS&metrics=CLICKS&metrics=TOTAL_EARNINGS&metrics=TOTAL_IMPRESSIONS&metrics=MATCHED_AD_REQUESTS&endDate.year=2021&alt=json&dateRange=CUSTOM

回复:

{u'endDate': {u'day': 13,u'month': 6,u'year': 2021},{u'name': u'PLATFORM_TYPE_NAME',{u'name': u'AD_UNIT_ID',{u'name': u'AD_REQUESTS',{u'currencyCode': u'USD',u'name': u'TOTAL_EARNINGS',{u'name': u'TOTAL_IMPRESSIONS',{u'name': u'MATCHED_AD_REQUESTS',u'startDate': {u'day': 13,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 Management API 使用 python 包(googleapiclient、oauth2client)。

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)