Issues (16)

examples/dataProviderAudience.php (1 issue)

Labels
Severity
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 audience grouped by segment
24
$from = new \DateTime("first day of this month");
25
$to = new \DateTime("today");
26
$groupBy = ["segment"];
27
28
/** @var stdClass[] */
29
$dataProviderAudiences = $adform->dataProviderAudience()->get($dataProviderId, $from, $to, $groupBy);
0 ignored issues
show
$dataProviderId of type string is incompatible with the type integer expected by parameter $dataProviderId of Audiens\AdForm\Manager\D...rAudienceManager::get(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
$dataProviderAudiences = $adform->dataProviderAudience()->get(/** @scrutinizer ignore-type */ $dataProviderId, $from, $to, $groupBy);
Loading history...
30
31
foreach ($dataProviderAudiences as $dataProviderAudience) {
32
    echo $dataProviderAudience->getDate()->format("d.m.Y.")." - ".$dataProviderAudience->getDataProvider()."\n";
33
    echo "Total: ".$dataProviderAudience->getTotal()."\n";
34
    echo "Unique: ".$dataProviderAudience->getUnique()."\n";
35
    echo "Total Hits: ".$dataProviderAudience->getTotalHits()."\n";
36
    echo "Unique Hits: ".$dataProviderAudience->getUniqueHits()."\n";
37
38
    echo "\n";
39
}
40