当前位置:网站首页>如何获取广告服务流量变现数据,助力广告效果分析?
如何获取广告服务流量变现数据,助力广告效果分析?
2022-07-26 01:11:00 【HMS Core】
广告服务(Ads Kit)提供流量变现服务,通过该服务开发者可以在自己的App中向用户展示Banner、原生、激励广告等多种形式的广告内容。而对于应用中已上线的广告位来说,因为涉及到收入,所以日常的数据监控显得尤为重要。
为此广告服务也提供了流量变现服务报表API(Publisher Service Reporting API),通过接入该API,开发者可以获取应用内广告变现相关数据,包括广告请求量、返回量、展示率、点击率等,让开发者可以依据数据对广告效果进行分析,从而及时调整投放策略。

开发者可根据返回的数据实现自己的报表展示效果
**那么如何获取流量变现数据呢?**以下是具体的集成步骤。
一.获取客户端ID和密钥
在获取变现数据前,我们要先有OAuth 2.0 客户端ID和密钥,用于生成调用报表API时传入的access_token,需要注意的是此处的客户端ID和密钥并不是指APPGallery Connect中应用的ClientID,而是通过在华为开发者联盟->凭证中创建的服务器应用的客户端ID。

- 注册成为开发者,完成实名认证。登录华为开发者联盟,点击右上角“管理中心”进入主页面。

- 进入“凭证”页面,创建项目,如果已有项目请跳过【步骤a】。
a. 选择“凭证”,根据下图标记顺序填入“项目名称”和“项目别名”新建项目。

b. 选中创建的项目,点击“确定”。

- 选择“OAuth 2.0 客户端 ID”创建客户端ID。

说明:
如果项目下已经存在“OAuth 2.0 客户端 ID”凭证,需要检查产品类型是否为服务器应用,如果是服务器应用可以跳过【步骤4】。
检查方式:点击操作一栏下的“编辑”按钮,查看“产品类型”。


如果不是“服务器应用”类型,需要重新创建“OAuth 2.0 客户端 ID”:

- 选择“服务器应用”,输入“产品名称”,选择“应用类型”和“默认语言”,点击“创建”;提示“客户端ID”和“密钥”,点击“确定”。

- 进入“我的API”页面,确认选中的项目,点击“申请新的HMS API服务”。

- 下拉找到“App Services”,点击“流量变现服务报表API”。

- 点击“启用”,开启流量变现服务报表API,之后就可以调用流量变现报表API了

在“停用”后,再次“启用”时,由于页面缓存等原因,生效时间是非实时生效的,需要等待大概6~10分钟。如果10分钟后没有生效,请重新进行尝试。
二.调用流量变现报表API
- 在调用流量变现报表API前需要先获取access_token鉴权信息。
调用接口:
POSThttps://oauth-login.cloud.huawei.com/oauth2/v3/token
请求示例:
POST /oauth2/v3/token HTTP/1.1Host: oauth-login.cloud.huawei.comContent-Type: application/x-www-form-urlencodedgrant_type=client_credentials& client_id=<客户端ID >& client_secret=<客户端密钥> ``` 请求示例截图:需要注意的是,客户端ID和密钥,是在开发者联盟界面获取的服务器应用的客户端ID和密钥,而不是在APPGallery Connect中创建的移动应用的客户端ID和密钥。2. 拿到access_token鉴权信息后,调用报表API。调用接口:POST https://ads.cloud.huawei.com/openapi/monetization/reports/v1/publisher俄罗斯站点需要调用以下接口:POST https://ads-drru.cloud.huawei.ru/openapi/monetization/reports/v1/publisher请求示例:POST /openapi/monetization/reports/v1/publisher HTTP/1.1 Content-Type: application/json Authorization: Bearer *** Accept: application/json Content-Length: 233
{ "start_date": "2022-06-01", "end_date": "2022-06-28", "filtering": { "currency": "CNY" }, "time_granularity": "STAT_TIME_GRANULARITY_DAILY", "page": 1, "page_size": 10 }
请求示例截图:  从截图中可以看到,数据已成功返回。具体请求参数,和响应参数可以参考[文档链接 ](https://developer.huawei.com/consumer/cn/doc/development/HMSCore-References/query-publisher-service-reports-0000001050933546#section20939514163519?ha_source=hms1)调用API获取变现报表数据后,开发者可以根据自己的需求去实现数据的展现形式。### 三.接入流量变现报表时的常见问题**调用流量变现服务报表API时返回access forbidden?**  原因分析:1. 在开发者联盟界面“API”栏目中没有开启对应项目的流量变现报表API开关。2. 流量报表API开关“启用”后,还没有等到权限生效,就调用报表API接口。3. 获取access_token鉴权信息时,传入的客户端ID和密钥,不是开发者联盟界面“凭证”中服务器应用的ID和密钥。**解决方法:**1. 开启流量报表API开关,在开发者联盟界面->我的API->选择对应的项目->点击“申请新的HMS API服务”,找到“流量变现服务报表API” 权限,点击“启用”。    2. 流量报表API开关“停用”后,再次“启用”时,并非实时生效,需要等待大概6~10分钟。3. 检查获取access_token鉴权信息时,传入的客户端ID是否是服务器应用的。在开发者联盟界面->凭证->找到对应的项目->点击项目下应用的编辑按钮,即可在产品类型一行看到应用类型。如果不是服务器应用,请更换服务器应用的客户端ID和密钥后重试。  **了解更多详情>>**访问[广告服务官网](https://developer.huawei.com/consumer/cn/hms/huawei-adskit?ha_source=hms1)访问[华为开发者联盟官网](http://developer.huawei.com/consumer/cn/hms?ha_source=hms1) 获取[开发指导文档](http://developer.huawei.com/consumer/cn/doc/development?ha_source=hms1) 华为移动服务开源仓库地址:[GitHub](http://github.com/HMS-Core)、[Gitee](http://gitee.com/hms-core)**关注我们,第一时间了解 HMS Core 最新技术资讯~**边栏推荐
- It will be easier to implement MES system by doing well in these four stages
- 【RTOS训练营】I2C和UART知识和预习安排 + 晚课提问
- Inverse matrix block matrix
- 【软件开发规范四】《应用系统安全编码规范》
- RHCE之at和crontab命令详解及chrony部署
- Tutorial on principles and applications of database system (054) -- MySQL query (16): usage of date time function
- How can MySQL just duplicate data?
- [RTOS training camp] course learning methods and C language knowledge (pointer, structure, function pointer, linked list) and student questions
- [translation paper] analysis of land cover classification using multi wavelength lidar system (2017)
- 健身房一年关店8000家,逆势盈利的工作室是怎么开的?
猜你喜欢
![[RTOS training camp] operation explanation, queue and ring buffer, queue - transmission data, queue - synchronization tasks and evening class questions](/img/59/0b671129e8cfaed28e2fe484ae0467.jpg)
[RTOS training camp] operation explanation, queue and ring buffer, queue - transmission data, queue - synchronization tasks and evening class questions

【RTOS训练营】I2C和UART知识和预习安排 + 晚课提问

1.30 upgrade bin file, add suffix and file length

Suddenly found an optimization artifact

Arthas watch 命令查看数组中对象的属性

985 associate professors in Colleges and universities sun their annual salary, and the provident fund tops the monthly salary of ordinary people. Netizen: it is worthy of being in Shanghai

【RTOS训练营】站在更高的角度学习C语言

Sqli-labs Less7

网络性能评估工具 ping/mtr
![[RTOS training camp] task scheduling (Continued), task comity, scheduling summary, queue and evening class questions](/img/0f/ca576a2f90aba4ddbb1f8b3e8a8ced.jpg)
[RTOS training camp] task scheduling (Continued), task comity, scheduling summary, queue and evening class questions
随机推荐
FastJson 处理泛型
《自然语言处理实战入门》深度学习基础 ---- attention 注意力机制 ,Transformer 深度解析与学习材料汇总
腾讯员工晒出薪资:真实985毕业薪资,大家看我还有救吗?网友:日薪?
Tutorial on principles and applications of database system (055) -- MySQL query (XVII): usage of mathematical functions
[Code] refers to the repeated number in the offer 03 array
The ultra comprehensive open source WinForm UI library meets all your desktop development needs!
Working principle of ZK rollups
Kubernetes Pod启动流程
Docker advanced -mysql master-slave replication
Fundamentals of MATLAB shift operation
109. Upload local files using SAP ui5 fileuploader control
[RTOS training camp] learn C language from a higher perspective
Lock upgrade: no lock, bias lock, lightweight lock, heavyweight lock
Android SQLite first groups and then sorts left concatenated queries
力扣 25. K 个一组翻转链表
《nlp入门+实战:第三章:梯度下降和反向传播 》
Travel + strategy accelerated landing, jietu new product matrix exposure
ASP. Net core configuration
全国一半人跑长沙,长沙一半人跑哪?
Codeforces Round #810 (Div. 2)A~C