1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
// Group.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 Group { |
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/groups'; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/* |
41
|
|
|
Retrieve Tags by Group |
42
|
|
|
https://dev.bitly.com/api-reference#getGroupTags |
43
|
|
|
*/ |
44
|
|
|
public function getGroupTags(string $group_guid) |
45
|
|
|
{ |
46
|
|
|
return $this->api->get($this->url.'/'.$group_guid.'/tags'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/* |
50
|
|
|
Get Click Metrics for a Group by referring networks |
51
|
|
|
https://dev.bitly.com/api-reference#GetGroupMetricsByReferringNetworks |
52
|
|
|
*/ |
53
|
|
|
public function getGroupMetricsByReferringNetworks(string $group_guid) |
54
|
|
|
{ |
55
|
|
|
return $this->api->get($this->url.'/'.$group_guid.'/referring_networks'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/* |
59
|
|
|
Retrieve Group Shorten Counts |
60
|
|
|
https://dev.bitly.com/api-reference#getGroupShortenCounts |
61
|
|
|
*/ |
62
|
|
|
public function getGroupShortenCounts(string $group_guid, array $params = array()) |
63
|
|
|
{ |
64
|
|
|
return $this->api->get($this->url.'/'.$group_guid.'/shorten_counts', $params); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/* |
68
|
|
|
Retrieve Groups |
69
|
|
|
https://dev.bitly.com/api-reference#getGroups |
70
|
|
|
*/ |
71
|
|
|
public function getGroups(array $params = array()) |
72
|
|
|
{ |
73
|
|
|
return $this->api->get($this->url, $params); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/* |
77
|
|
|
Retrieve Group Preferences |
78
|
|
|
https://dev.bitly.com/api-reference#getGroupPreferences |
79
|
|
|
*/ |
80
|
|
|
public function getGroupPreferences(string $group_guid) |
81
|
|
|
{ |
82
|
|
|
return $this->api->get($this->url.'/'.$group_guid.'/preferences'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/* |
86
|
|
|
Update Group Preferences |
87
|
|
|
https://dev.bitly.com/api-reference#updateGroupPreferences |
88
|
|
|
*/ |
89
|
|
|
public function updateGroupPreferences(string $group_guid, array $params) |
90
|
|
|
{ |
91
|
|
|
return $this->api->patch($this->url.'/'.$group_guid.'/preferences', $params); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/* |
95
|
|
|
Retrieve Bitlinks by Group |
96
|
|
|
https://dev.bitly.com/api-reference#getBitlinksByGroup |
97
|
|
|
*/ |
98
|
|
|
public function getBitlinksByGroup(string $group_guid, array $params = array()) |
99
|
|
|
{ |
100
|
|
|
return $this->api->get($this->url.'/'.$group_guid.'/bitlinks', $params); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/* |
104
|
|
|
Get Click Metrics for a Group by countries |
105
|
|
|
https://dev.bitly.com/api-reference#getGroupMetricsByCountries |
106
|
|
|
*/ |
107
|
|
|
public function getGroupMetricsByCountries(string $group_guid, array $params = array()) |
108
|
|
|
{ |
109
|
|
|
return $this->api->get($this->url.'/'.$group_guid.'/countries', $params); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/* |
113
|
|
|
Retrieve Sorted Bitlinks for Group |
114
|
|
|
https://dev.bitly.com/api-reference#getSortedBitlinks |
115
|
|
|
*/ |
116
|
|
|
public function getSortedBitlinks(string $group_guid, array $params = array(), string $sort = 'clicks') |
117
|
|
|
{ |
118
|
|
|
return $this->api->get($this->url.'/'.$group_guid.'/bitlinks/'.$sort, $params); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/* |
122
|
|
|
Update a Group |
123
|
|
|
https://dev.bitly.com/api-reference#updateGroup |
124
|
|
|
*/ |
125
|
|
|
public function updateGroup(string $group_guid, array $params) |
126
|
|
|
{ |
127
|
|
|
return $this->api->patch($this->url.'/'.$group_guid, $params); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/* |
131
|
|
|
Retrieve a Group |
132
|
|
|
https://dev.bitly.com/api-reference#getGroup |
133
|
|
|
*/ |
134
|
|
|
public function getGroup(string $group_guid) |
135
|
|
|
{ |
136
|
|
|
return $this->api->get($this->url.'/'.$group_guid); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/* |
140
|
|
|
Get Click Metrics for a Group by City |
141
|
|
|
https://dev.bitly.com/api-reference#getGroupMetricsByCities |
142
|
|
|
*/ |
143
|
|
|
public function getGroupMetricsByCities(string $group_guid, array $params = array()) |
144
|
|
|
{ |
145
|
|
|
return $this->api->get($this->url.'/'.$group_guid."/cities", $params); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/* |
149
|
|
|
Get Click Metrics for a Group by Device Type |
150
|
|
|
https://dev.bitly.com/api-reference#getGroupMetricsByDevices |
151
|
|
|
*/ |
152
|
|
|
public function getGroupMetricsByDevices(string $group_guid, array $params = array()) |
153
|
|
|
{ |
154
|
|
|
return $this->api->get($this->url.'/'.$group_guid."/devices", $params); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/* |
158
|
|
|
Get clicks by group |
159
|
|
|
https://dev.bitly.com/api-reference#getGroupClicks |
160
|
|
|
*/ |
161
|
|
|
public function getGroupClicks(string $group_guid, array $params = array()) |
162
|
|
|
{ |
163
|
|
|
return $this->api->get($this->url.'/'.$group_guid."/clicks", $params); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/* |
167
|
|
|
Retrieve QR Code Logo Images |
168
|
|
|
https://dev.bitly.com/api-reference/#getQRLogoImagesByGroup |
169
|
|
|
*/ |
170
|
|
|
public function getQRLogoImagesByGroup(string $group_guid) |
171
|
|
|
{ |
172
|
|
|
return $this->api->get($this->url.'/'.$group_guid."/qr/images"); |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|