|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// Campaign.php |
|
4
|
|
|
################################################# |
|
5
|
|
|
## |
|
6
|
|
|
## PHPLicengine |
|
7
|
|
|
## |
|
8
|
|
|
################################################# |
|
9
|
|
|
## Copyright 2009-{current_year} PHPLicengine |
|
10
|
|
|
## |
|
11
|
|
|
## Licensed under the Apache License, Version 2.0 (the "License"); |
|
12
|
|
|
## you may not use this file except in compliance with the License. |
|
13
|
|
|
## You may obtain a copy of the License at |
|
14
|
|
|
## |
|
15
|
|
|
## http://www.apache.org/licenses/LICENSE-2.0 |
|
16
|
|
|
## |
|
17
|
|
|
## Unless required by applicable law or agreed to in writing, software |
|
18
|
|
|
## distributed under the License is distributed on an "AS IS" BASIS, |
|
19
|
|
|
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
20
|
|
|
## See the License for the specific language governing permissions and |
|
21
|
|
|
## limitations under the License. |
|
22
|
|
|
################################################# |
|
23
|
|
|
|
|
24
|
|
|
namespace PHPLicengine\Service; |
|
25
|
|
|
use PHPLicengine\Exception\ResponseException; |
|
26
|
|
|
use PHPLicengine\Exception\CurlException; |
|
27
|
|
|
use PHPLicengine\Api\ApiInterface; |
|
28
|
|
|
|
|
29
|
|
|
class Campaign { |
|
30
|
|
|
|
|
31
|
|
|
private $url; |
|
32
|
|
|
private $api; |
|
33
|
|
|
|
|
34
|
|
|
public function __construct(ApiInterface $api) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->api = $api; |
|
37
|
|
|
$this->url = 'https://api-ssl.bitly.com/v4'; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/* |
|
41
|
|
|
Create Channel |
|
42
|
|
|
https://dev.bitly.com/api-reference#createChannel |
|
43
|
|
|
*/ |
|
44
|
|
|
public function createChannel(array $params) |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->api->post($this->url.'/channels', $params); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/* |
|
50
|
|
|
Retrieve Channels |
|
51
|
|
|
https://dev.bitly.com/api-reference#getChannels |
|
52
|
|
|
*/ |
|
53
|
|
|
public function getChannels(array $params) |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->api->get($this->url.'/channels', $params); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/* |
|
59
|
|
|
Create Campaign |
|
60
|
|
|
https://dev.bitly.com/api-reference#createCampaign |
|
61
|
|
|
*/ |
|
62
|
|
|
public function createCampaign(array $params) |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->api->post($this->url.'/campaigns', $params); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/* |
|
68
|
|
|
Retrieve Campaigns |
|
69
|
|
|
https://dev.bitly.com/api-reference#getCampaigns |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getCampaigns(array $params) |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->api->get($this->url.'/campaigns', $params); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/* |
|
77
|
|
|
Retrieve a Campaign |
|
78
|
|
|
https://dev.bitly.com/api-reference#getCampaign |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getCampaign(string $campaign_guid) |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->api->get($this->url.'/campaigns/'.$campaign_guid); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/* |
|
86
|
|
|
Update Campaign |
|
87
|
|
|
https://dev.bitly.com/api-reference#updateCampaign |
|
88
|
|
|
*/ |
|
89
|
|
|
public function updateCampaign(string $campaign_guid, array $params) |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->api->patch($this->url.'/campaigns/'.$campaign_guid, $params); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/* |
|
95
|
|
|
Get A Channel |
|
96
|
|
|
https://dev.bitly.com/api-reference#getChannel |
|
97
|
|
|
*/ |
|
98
|
|
|
public function getChannel(string $channel_guid) |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->api->get($this->url.'/channels/'.$channel_guid); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/* |
|
104
|
|
|
Update A Channel |
|
105
|
|
|
https://dev.bitly.com/api-reference#updateChannel |
|
106
|
|
|
*/ |
|
107
|
|
|
public function updateChannel(string $channel_guid, array $params) |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->api->patch($this->url.'/channels/'.$channel_guid, $params); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
} |
|
113
|
|
|
|