1

我正在使用google-api-php-client从我们的服务器远程获取 AdmobMediation 报告

一切正常,除了响应报告仅与“Admob Network”相关,而不是“Mediation report”

因此,指标不完整

所以我有两个问题:

  1. 有没有办法使用 SDK 获取中介报告,而不仅仅是 Admob 网络报告?

  2. 有没有办法使用 php SDK 下载我们在“Admob 仪表板”上制作的已保存报告?

$startDate = '2019-04-01';
$endDate = '2019-04-09';
$AppId = 'xxxx';
$accountId = 'xxxx';

/*
    Create the client
*/
$client = new Google_Client();
$client->addScope('https://www.googleapis.com/auth/adsense.readonly');
$client->setAccessType('offline');

/*
    Authentication
*/
$client->setClientId('xxx');
$client->setClientSecret('xxx');
$client->setRedirectUri("urn:ietf:wg:oauth:2.0:oob");
$refreshedAccessToken = $client->refreshToken('xxx');
$client->setAccessToken($refreshedAccessToken);

/*
    Create the service
*/
$service = new Google_Service_AdSense($client);


/*
    Get the result
*/
$metrics = array(
    'AD_REQUESTS', 'VIEWED_IMPRESSIONS', 'IMPRESSIONS_RPM', 'CLICKS', 'REACHED_AD_REQUESTS',
    'IMPRESSIONS_CTR', 'COST_PER_CLICK', 'AD_REQUESTS_RPM', 'EARNINGS'
);
$filter = array(
    'APP_ID==' . $AppId
);
$optParams = array(
    'currency' => 'USD',
    'metric' => $metrics,
    'dimension' => 'DATE',
    'sort' => '+DATE',
    'filter' => $filter,
    'useTimezoneReporting'=>true
);
$result = $service->accounts_reports->generate($accountId, $startDate, $endDate, $optParams);

4

1 回答 1