megaads / ga-service
服务从谷歌分析、谷歌广告获取报告
1.2
2020-02-27 09:45 UTC
Requires
- php: >=5.6.4
- google/apiclient: ^2.0
- googleads/googleads-php-lib: ^38.0
- phpoffice/phpexcel: 1.8.1
This package is auto-updated.
Last update: 2024-09-27 20:02:56 UTC
README
## 安装,添加到 composer.json 文件中
"require": {
"megaads/ga-service": "^1.2"
}
## 从谷歌分析获取报告
$KEY_FILE_LOCATION = '../config/client-secrets.json';
$name = 'Chiaki';
$filter = [
'viewId' => 'xxxxxxxx',
'from' => '2020-02-01',
'to' => '2020-02-25',
'metrics' => [
'ga:sessions', 'ga:users', 'ga:bounces'
]
];
$gaTransfer = new \GaServices\GoogleAnalytic();
$items = $gaTransfer->report($name, $KEY_FILE_LOCATION, $filter);
## 谷歌广告
\\ Get cost ads of account
$adsCostAccount = new \GaServices\AdsCostAccount();
$fileConfig = '../config/adsapi_php.ini';
$customerId = 'xxx-xxx-xxxx';
$filter = ['from' => '2020-01-01', 'to' => '2020-01-29']
$cost = $adsCostAccount->report($customerId, $fileConfig, $filter);