0

从 google adsense management api v 1.4 生成报告时,如何在此处列出: https ://developers.google.com/adsense/management/v1.4/reference/accounts/reports/generate

我查看了此处给出的指标和维度: https ://developers.google.com/adsense/management/metrics-dimensions

我试图在请求中传递这些值,并且它对我来说工作正常:

startDate=2015-07-07&
endDate=2015-07-12&
dimension=AD_UNIT_NAME&
metric=AD_REQUESTS_CTR

但是我应该如何传递多个指标值?例如,如果我想要度量值:

AD_REQUESTS_RPM , 
AD_REQUESTS_RPM ,
CLICKS , 
EARNINGS etc 

我试图将它们与正常和 url 编码的值分开

":" 
","
" " (space) 

但没有什么对我有用,我收到了这个错误:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalidParameter",
    "message": "Invalid value 'AD_REQUESTS_CTR:AD_REQUESTS_RPM'. Values must match the following regular expression: '[a-zA-Z_]+'",
    "locationType": "parameter",
    "location": "metric[0]"
   }
  ],
  "code": 400,
  "message": "Invalid value 'AD_REQUESTS_CTR:AD_REQUESTS_RPM'. Values must match the following regular expression: '[a-zA-Z_]+'"
 }
}
4

1 回答 1

0

所以我找到了传递多个度量和维度值的解决方案,我认为它是 google adsense 团队的一个非常糟糕的 api 设计。

这是它的工作原理:

GET https://www.googleapis.com/adsense/v1.4/accounts/pub-423423423432/reports?alt=json&
startDate=2015-07-07&
endDate=2015-07-12&
dimension=AD_UNIT_NAME&
metric=AD_REQUESTS_RPM& 
metric=AD_REQUESTS_RPM&
metric=CLICKS& 
metric=EARNINGS
于 2015-07-14T13:40:18.240 回答