Audiens /
adform-client
| 1 | <?php |
||
| 2 | |||
| 3 | require '../vendor/autoload.php'; |
||
| 4 | |||
| 5 | $username = '{yourUsername}'; |
||
| 6 | $password = '{yourPassword}'; |
||
| 7 | $dataProviderId = '{yourDataProviderId}'; |
||
| 8 | |||
| 9 | // create the API client instance |
||
| 10 | try { |
||
| 11 | $redisConfig = [ |
||
| 12 | 'scheme' => 'tcp', |
||
| 13 | 'host' => 'localhost', |
||
| 14 | 'port' => 6379, |
||
| 15 | ]; |
||
| 16 | $cache = new Audiens\AdForm\Cache\RedisCache($redisConfig); |
||
| 17 | $adform = new Audiens\AdForm\Client($username, $password, $cache); |
||
| 18 | |||
| 19 | } catch (Audiens\AdForm\Exception\OauthException $e) { |
||
| 20 | exit($e->getMessage()); |
||
| 21 | } |
||
| 22 | |||
| 23 | // Get data usage grouped by segment |
||
| 24 | $from = new DateTime('first day of this month'); |
||
| 25 | $to = new DateTime('today'); |
||
| 26 | $groupBy = ['segment']; |
||
| 27 | /** @var stdClass[] */ |
||
| 28 | $dataUsage = $adform->dataUsage()->get($dataProviderId, $from, $to, $groupBy); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 29 | foreach ($dataUsage as $usage) { |
||
| 30 | echo $usage->segmentsGroup.": ".$usage->revenue."\n"; |
||
| 31 | } |
||
| 32 |