php 对接Bigo海外广告平台收益接口Reporting API

时间:2024-04-14 19:53:47

今天对接的是Bigo广告reporting api接口,拉取广告收益回来自己做统计。记录分享给大家
首先是文档地址,进入到BIGO后台就能看到文档地址以及参数:
文档地址:https://www.bigossp.com/guide/sdk/reportingApi/doc?type=1
在这里插入图片描述
在这里插入图片描述

接入这些第三方广告平台,流程基本上一样,拿好参数之后可以直接开始对接了,我直接贴代码出来:

const serverHost = "https://www.bigossp.com/open/report/media/v1.0";

$param = [
            'startDate' => $date,
            'endDate' => $date,
            'pageNo' => 1,
            'pageSize' => 10000,
            'indicators' => ["clientReqCnt", "clientFillCnt", "adImprCnt", "adClickCnt", "eincome"],
            'breakDowns' => ["pkgName", "appKey", "appOs", "slotId", "adType"],
        ];
        $timestamp = time() * 1000;
        $headers = array(
            'Content-Type' => ' application/json',
            'X-BIGO-DeveloperId' => self::Developer_Id,
            'X-BIGO-Sign' => sha1(self::Developer_Id . '-' . $timestamp . '-' . self::Api_Key) . '.' . $timestamp
        );

        $reqUrl = self::serverHost;
        $client = new Client();
        $response = $client->request('POST', $reqUrl, ['headers' => $headers, 'json' => $param]);
        $result = json_decode($response->getBody()->getContents(), true);
        $model_type = [
            'Android' => 1,
            'iOS' => 2,
        ];
        ......下面是自己的逻辑代码

需要注意的几个点就是,请求头设置,按照文档要求,将参数组装好设置好请求头,indicators是接口返回数据,BIGO数据返回比较少,就看到只有这么几个,对应的是请求数,填充数,展示数,点击数,收益,然后数据分类类型就根据自己需要选择

$param = [
            'startDate' => $date,
            'endDate' => $date,
            'pageNo' => 1,
            'pageSize' => 10000,
            'appKey' => array_keys($third_apps),
            'indicators' => ["clientReqCnt", "clientFillCnt", "adImprCnt", "adClickCnt", "eincome"],
            'breakDowns' => ["pkgName", "appKey", "appOs", "slotId", "adType"],
        ];

上面我们只拿我们需要的应用APPKEY,数据类型为数组,自己组装好

 $model_type = [
            'Android' => 1,
            'iOS' => 2,
        ];
  

然后就是返回设备类型,安卓返回的是Android,苹果返回的是iOS,大家根据自己的需要存储
以上是我对接BIGO广告收益接口代码,欢迎大家交流学习,希望能对你有帮助。