Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Service AdMob:如何查询AdMob以获取我的应用程序收入_Service_Web_Admob - Fatal编程技术网

Service AdMob:如何查询AdMob以获取我的应用程序收入

Service AdMob:如何查询AdMob以获取我的应用程序收入,service,web,admob,Service,Web,Admob,我已经为我的Android应用程序配置了adMob,没有问题 现在,我正在寻找任何方法来检查我的应用程序在任何特定时刻的收入(如果可能的话,分别检查每个应用程序的收入) 有人知道我是否可以使用任何API、库或Web服务来访问我的AdMob帐户并获取有关我的应用程序统计信息等等 我已经检查了官方的APK,但它似乎只打算在你的应用程序中显示广告,其他什么都没有 提前谢谢我自己回答 我在做一些研究,我发现在AdMob上最近的更改以及迁移到AdSense之后,您必须使用AdSense API来获取这些信

我已经为我的Android应用程序配置了adMob,没有问题

现在,我正在寻找任何方法来检查我的应用程序在任何特定时刻的收入(如果可能的话,分别检查每个应用程序的收入)

有人知道我是否可以使用任何API、库或Web服务来访问我的AdMob帐户并获取有关我的应用程序统计信息等等

我已经检查了官方的APK,但它似乎只打算在你的应用程序中显示广告,其他什么都没有

提前谢谢

我自己回答

我在做一些研究,我发现在AdMob上最近的更改以及迁移到AdSense之后,您必须使用AdSense API来获取这些信息

特别是,每个Android应用程序都与一个“adunit”id相关联,因此,如果您想查看您可能使用的任何特定应用程序的信息:

使用以下数据:

accountId = your Publisher ID (pub-XXXXXXX)
startDate and endDate = The interval of dates you want to check
dimension = AD_UNIT_ID
metric = EARNINGS
通过此查询,您将获得所需信息,以应用程序分隔

您将以JSON格式获得结果。

有一个可用于获取AdMob特定数据的方法

它提供了生成可用报告的可能性。它可以简单到:

curl -X POST https://admob.googleapis.com/v1/accounts/<your_publisher_id>/mediationReport:generate \
       -H "Authorization: Bearer <access_token>" \
       -H "Content-Type: application/json" \
       --data @- << EOF
{
  "report_spec": {
    "date_range": {
      "start_date": {"year": 2020, "month": 4, "day": 1},
      "end_date": {"year": 2020, "month": 4, "day": 1}
    },
    "dimensions": ["AD_SOURCE", "AD_UNIT", "PLATFORM"],
    "metrics": ["ESTIMATED_EARNINGS"]
  }
}
EOF
curl-X POSThttps://admob.googleapis.com/v1/accounts//mediationReport:generate \
-H“授权:持票人
  • 爪哇:
  • 获取Oauth2.0访问令牌 使用oauth2l 安装:

    oauth2l头文件——jsonhttps://www.googleapis.com/auth/admob.report
    
    路径_到_secret_json-来自谷歌云控制台上的凭证页面

    卷曲 将oauth2_客户端id替换为“云项目凭据-oauth2.0客户端id”页面中的id。()

    &重定向\u uri=urn%3AETF%3Awg%3OAuth%3A2.0%3OOB

    • 以匿名浏览器模式打开此链接
    • 按照说明,接受带有AdMob publisher帐户的辅音屏幕
    • 复制代码,以下请求将需要该代码:
    curl-L\
    -d“客户机id=”\
    -d“客户机密=”\
    -d“授权类型=授权代码”\
    -d“代码=”\
    -d“redirect_uri=urn:ietf:wg:oauth:2.0:oob”\
    https://accounts.google.com/o/oauth2/token
    
    oaut2.0客户端id页上可以找到oaut2\u客户端id和oauth2\u机密

    答复:

    {
      "access_token": "<access_token>",
      "expires_in": 3600,
      "refresh_token": "<refresh_token>",
      "scope": "https://www.googleapis.com/auth/admob.report",
      "token_type": "Bearer"
    }
    
    {
    “访问令牌”:“,
    “expires_in”:3600,
    “刷新令牌”:“”,
    “范围”:https://www.googleapis.com/auth/admob.report",
    “令牌类型”:“承载者”
    }
    
    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
    
    {
      "access_token": "<access_token>",
      "expires_in": 3600,
      "refresh_token": "<refresh_token>",
      "scope": "https://www.googleapis.com/auth/admob.report",
      "token_type": "Bearer"
    }