-
Notifications
You must be signed in to change notification settings - Fork 2
/
examples.php
68 lines (55 loc) · 1.46 KB
/
examples.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
use SamanthaAdrichem\DaisyconApi\Exception\Http\NotFoundException;
use SamanthaAdrichem\DaisyconApi\Exception\Http\HttpException;
use SamanthaAdrichem\DaisyconApi\MethodEnum;
use SamanthaAdrichem\DaisyconApi\RestClient;
// Setup client
$restClient = new RestClient(
'myClientId',
'myClientSecret'
);
// Fetch my publisher account
var_dump($restClient->getPublishers());
// Fetch my publisher Ids
var_dump($restClient->getPublisherIds());
// Fetch my advertiser account
var_dump($restClient->getAdvertisers());
// Fetch my advertiser Ids
var_dump($restClient->getAdvertiserIds());
// Fetch my lead generation account
var_dump($restClient->getLeadGeneration());
// Fetch my lead generation Ids
var_dump($restClient->getLeadGenerationIds());
// Catch errors
try
{
$restClient->performCall('/some/non/existing/url');
}
// There are specific types, you can catch per type
catch (NotFoundException $exception)
{
var_dump($exception->getMessage());
}
// Or just catch all HttpExceptions
catch (HttpException $exception)
{
var_dump($exception->getMessage());
}
// Or just all exceptions
catch (Exception $exception)
{
var_dump($exception->getMessage());
}
// You can also check the last response code
var_dump($restClient->getLastResponseCode());
// Get the response headers
$responseHeaders = [];
$restClient->performCall(
'/some/existing/url',
MethodEnum::Get,
[],
$responseHeaders
);
var_dump($responseHeaders);
// Enable sandbox mode
$restClient->enableSandboxMode();