android - 如何获取 AdMob 信息,例如 Android 应用中的展示次数?

标签 android admob reporting ads google-admob

我需要在 Android 应用中跟踪来自 AdMob 的报告。我需要展示次数、点击次数、点击率、ecpm 和预估收入等信息。有某种支持此功能的 API 吗?

最佳答案

AdMob API:https://developers.google.com/admob/api

请求

curl -X POST https://admob.googleapis.com/v1/accounts/<your_publisher_id>/networkReport:generate \
       -H "'Authorization: Bearer <oauth2_access_token>" \
       -H "Content-Type: application/json" \
       --data @- << EOF
{
  "report_spec": {
    "date_range": {
      "start_date": {"year": 2020, "month": 4, "day": 2},
      "end_date": {"year": 2020, "month": 4, "day": 2}
    },
    "dimensions": ["APP", "AD_UNIT"],
    "metrics": ["AD_REQUESTS", "IMPRESSIONS", "ESTIMATED_EARNINGS"]
  }
}
EOF

获取Oauth2.0访问 token

使用 oauth2l

安装:https://github.com/google/oauth2l

oauth2l header --json <path_to_secret_json> https://www.googleapis.com/auth/admob.report

path_to_secret_json - 来自谷歌云控制台上的凭据页面。

curl

oauth2_client_id 替换为您在“Cloud project credentials - OAuth 2.0 client IDs”页面中的那个。 ( https://console.developers.google.com/apis/credentials?project= )

https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadmob.report&response_type=code&client_id= &redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob

  • 以隐身浏览器模式打开此链接;
  • 按照说明进行操作,并使用 AdMob 发布商帐户接受辅音屏幕;
  • 复制代码,以下请求需要它:
curl -L \
-d "client_id=<oauth2_client_id>" \
-d "client_secret=<oauth2_secret>" \
-d "grant_type=authorization_code" \
-d "code=<sign_in_code_from_the_previous_step>" \
-d "redirect_uri=urn:ietf:wg:oauth:2.0:oob" \
https://accounts.google.com/o/oauth2/token

oaut2_client_idoauth2_secret 可以在 OAuth 2.0 客户端 ID 页面上找到。

响应:

{
  "access_token": "<access_token>",
  "expires_in": 3600,
  "refresh_token": "<refresh_token>",
  "scope": "https://www.googleapis.com/auth/admob.report",
  "token_type": "Bearer"
}

有关开发人员文档的更多详细信息:https://developers.google.com/admob/api/v1/getting-started

关于android - 如何获取 AdMob 信息,例如 Android 应用中的展示次数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41956641/

相关文章:

android - 用 dagger2 注入(inject)测试模块

android - 在 eclipse ADT 中使用同一个 android 项目的多个目标

android - 各个方向的应用程序

android - 你好 OpenCV Android

ios - Xcode5 Google Admob sdk 链接器命令失败,退出代码为 1

hadoop - 临时报告 Hadoop

android - 安装应用形式奖励视频后如何奖励用户 - android

android - 找不到 com.google.plus.platform 的提供商信息

visual-studio - Visual Studio 11 Beta/IIS 7.5:找不到Microsoft.ReportViewer.Common V11

selenium - 为 WebdriverIO/Cucumber 框架生成 HTML 报告