@@ -25,160 +25,160 @@ |
||
25 | 25 | |
26 | 26 | class Result { |
27 | 27 | |
28 | - protected $error; |
|
29 | - protected $message; |
|
30 | - protected $headers; |
|
31 | - protected $curlInfo; |
|
32 | - protected $reasonPhrases = array( |
|
33 | - // INFORMATIONAL CODES |
|
34 | - 100 => 'Continue', |
|
35 | - 101 => 'Switching Protocols', |
|
36 | - 102 => 'Processing', |
|
37 | - // SUCCESS CODES |
|
38 | - 200 => 'OK', |
|
39 | - 201 => 'Created', |
|
40 | - 202 => 'Accepted', |
|
41 | - 203 => 'Non-Authoritative Information', |
|
42 | - 204 => 'No Content', |
|
43 | - 205 => 'Reset Content', |
|
44 | - 206 => 'Partial Content', |
|
45 | - 207 => 'Multi-status', |
|
46 | - 208 => 'Already Reported', |
|
47 | - // REDIRECTION CODES |
|
48 | - 300 => 'Multiple Choices', |
|
49 | - 301 => 'Moved Permanently', |
|
50 | - 302 => 'Found', |
|
51 | - 303 => 'See Other', |
|
52 | - 304 => 'Not Modified', |
|
53 | - 305 => 'Use Proxy', |
|
54 | - 306 => 'Switch Proxy', // Deprecated |
|
55 | - 307 => 'Temporary Redirect', |
|
56 | - // CLIENT ERROR |
|
57 | - 400 => 'Bad Request', |
|
58 | - 401 => 'Unauthorized', |
|
59 | - 402 => 'Payment Required', |
|
60 | - 403 => 'Forbidden', |
|
61 | - 404 => 'Not Found', |
|
62 | - 405 => 'Method Not Allowed', |
|
63 | - 406 => 'Not Acceptable', |
|
64 | - 407 => 'Proxy Authentication Required', |
|
65 | - 408 => 'Request Time-out', |
|
66 | - 409 => 'Conflict', |
|
67 | - 410 => 'Gone', |
|
68 | - 411 => 'Length Required', |
|
69 | - 412 => 'Precondition Failed', |
|
70 | - 413 => 'Request Entity Too Large', |
|
71 | - 414 => 'Request-URI Too Large', |
|
72 | - 415 => 'Unsupported Media Type', |
|
73 | - 416 => 'Requested range not satisfiable', |
|
74 | - 417 => 'Expectation Failed', |
|
75 | - 418 => 'I\'m a teapot', |
|
76 | - 422 => 'Unprocessable Entity', |
|
77 | - 423 => 'Locked', |
|
78 | - 424 => 'Failed Dependency', |
|
79 | - 425 => 'Unordered Collection', |
|
80 | - 426 => 'Upgrade Required', |
|
81 | - 428 => 'Precondition Required', |
|
82 | - 429 => 'Too Many Requests', |
|
83 | - 431 => 'Request Header Fields Too Large', |
|
84 | - // SERVER ERROR |
|
85 | - 500 => 'Internal Server Error', |
|
86 | - 501 => 'Not Implemented', |
|
87 | - 502 => 'Bad Gateway', |
|
88 | - 503 => 'Service Unavailable', |
|
89 | - 504 => 'Gateway Time-out', |
|
90 | - 505 => 'HTTP Version not supported', |
|
91 | - 506 => 'Variant Also Negotiates', |
|
92 | - 507 => 'Insufficient Storage', |
|
93 | - 508 => 'Loop Detected', |
|
94 | - 511 => 'Network Authentication Required' |
|
95 | - ); |
|
96 | - |
|
97 | - public function __construct($body, $headers, $curlInfo) |
|
98 | - { |
|
99 | - $this->body = $body; |
|
100 | - $this->headers = $headers; |
|
101 | - $this->curlInfo = $curlInfo; |
|
102 | - } |
|
103 | - |
|
104 | - public function isError () |
|
105 | - { |
|
106 | - return isset($this->getResponseObject()->errors) && $this->getResponseObject()->errors; |
|
107 | - } |
|
28 | + protected $error; |
|
29 | + protected $message; |
|
30 | + protected $headers; |
|
31 | + protected $curlInfo; |
|
32 | + protected $reasonPhrases = array( |
|
33 | + // INFORMATIONAL CODES |
|
34 | + 100 => 'Continue', |
|
35 | + 101 => 'Switching Protocols', |
|
36 | + 102 => 'Processing', |
|
37 | + // SUCCESS CODES |
|
38 | + 200 => 'OK', |
|
39 | + 201 => 'Created', |
|
40 | + 202 => 'Accepted', |
|
41 | + 203 => 'Non-Authoritative Information', |
|
42 | + 204 => 'No Content', |
|
43 | + 205 => 'Reset Content', |
|
44 | + 206 => 'Partial Content', |
|
45 | + 207 => 'Multi-status', |
|
46 | + 208 => 'Already Reported', |
|
47 | + // REDIRECTION CODES |
|
48 | + 300 => 'Multiple Choices', |
|
49 | + 301 => 'Moved Permanently', |
|
50 | + 302 => 'Found', |
|
51 | + 303 => 'See Other', |
|
52 | + 304 => 'Not Modified', |
|
53 | + 305 => 'Use Proxy', |
|
54 | + 306 => 'Switch Proxy', // Deprecated |
|
55 | + 307 => 'Temporary Redirect', |
|
56 | + // CLIENT ERROR |
|
57 | + 400 => 'Bad Request', |
|
58 | + 401 => 'Unauthorized', |
|
59 | + 402 => 'Payment Required', |
|
60 | + 403 => 'Forbidden', |
|
61 | + 404 => 'Not Found', |
|
62 | + 405 => 'Method Not Allowed', |
|
63 | + 406 => 'Not Acceptable', |
|
64 | + 407 => 'Proxy Authentication Required', |
|
65 | + 408 => 'Request Time-out', |
|
66 | + 409 => 'Conflict', |
|
67 | + 410 => 'Gone', |
|
68 | + 411 => 'Length Required', |
|
69 | + 412 => 'Precondition Failed', |
|
70 | + 413 => 'Request Entity Too Large', |
|
71 | + 414 => 'Request-URI Too Large', |
|
72 | + 415 => 'Unsupported Media Type', |
|
73 | + 416 => 'Requested range not satisfiable', |
|
74 | + 417 => 'Expectation Failed', |
|
75 | + 418 => 'I\'m a teapot', |
|
76 | + 422 => 'Unprocessable Entity', |
|
77 | + 423 => 'Locked', |
|
78 | + 424 => 'Failed Dependency', |
|
79 | + 425 => 'Unordered Collection', |
|
80 | + 426 => 'Upgrade Required', |
|
81 | + 428 => 'Precondition Required', |
|
82 | + 429 => 'Too Many Requests', |
|
83 | + 431 => 'Request Header Fields Too Large', |
|
84 | + // SERVER ERROR |
|
85 | + 500 => 'Internal Server Error', |
|
86 | + 501 => 'Not Implemented', |
|
87 | + 502 => 'Bad Gateway', |
|
88 | + 503 => 'Service Unavailable', |
|
89 | + 504 => 'Gateway Time-out', |
|
90 | + 505 => 'HTTP Version not supported', |
|
91 | + 506 => 'Variant Also Negotiates', |
|
92 | + 507 => 'Insufficient Storage', |
|
93 | + 508 => 'Loop Detected', |
|
94 | + 511 => 'Network Authentication Required' |
|
95 | + ); |
|
96 | + |
|
97 | + public function __construct($body, $headers, $curlInfo) |
|
98 | + { |
|
99 | + $this->body = $body; |
|
100 | + $this->headers = $headers; |
|
101 | + $this->curlInfo = $curlInfo; |
|
102 | + } |
|
103 | + |
|
104 | + public function isError () |
|
105 | + { |
|
106 | + return isset($this->getResponseObject()->errors) && $this->getResponseObject()->errors; |
|
107 | + } |
|
108 | 108 | |
109 | - public function getDescription () |
|
110 | - { |
|
111 | - return $this->getResponseObject()->description; |
|
112 | - } |
|
113 | - |
|
114 | - public function getHeaders() |
|
115 | - { |
|
116 | - return $this->headers; |
|
117 | - } |
|
118 | - |
|
119 | - public function getResponse() |
|
120 | - { |
|
121 | - return $this->body; |
|
122 | - } |
|
123 | - |
|
124 | - public function getResponseObject() |
|
125 | - { |
|
126 | - return json_decode($this->body); |
|
127 | - } |
|
128 | - |
|
129 | - public function getResponseArray () |
|
130 | - { |
|
131 | - return json_decode($this->body, true); |
|
132 | - } |
|
133 | - |
|
134 | - public function getResponseCode() |
|
135 | - { |
|
136 | - return $this->curlInfo['http_code']; |
|
137 | - } |
|
138 | - |
|
139 | - public function getReasonPhrase() |
|
140 | - { |
|
141 | - return $this->reasonPhrases[$this->curlInfo['http_code']]; |
|
142 | - } |
|
143 | - |
|
144 | - public function getContentType() |
|
145 | - { |
|
146 | - return $this->curlInfo['content_type']; |
|
147 | - } |
|
148 | - |
|
149 | - public function isOk() |
|
150 | - { |
|
151 | - return ($this->curlInfo['http_code'] === 200); |
|
152 | - } |
|
153 | - |
|
154 | - public function isSuccess() |
|
155 | - { |
|
156 | - return (200 <= $this->curlInfo['http_code'] && 300 > $this->curlInfo['http_code']); |
|
157 | - } |
|
158 | - |
|
159 | - public function isNotFound() |
|
160 | - { |
|
161 | - return ($this->curlInfo['http_code'] === 404); |
|
162 | - } |
|
163 | - |
|
164 | - public function isInformational() |
|
165 | - { |
|
166 | - return ($this->curlInfo['http_code'] >= 100 && $this->curlInfo['http_code'] < 200); |
|
167 | - } |
|
168 | - |
|
169 | - public function isRedirect() |
|
170 | - { |
|
171 | - return (300 <= $this->curlInfo['http_code'] && 400 > $this->curlInfo['http_code']); |
|
172 | - } |
|
173 | - |
|
174 | - public function isClientError() |
|
175 | - { |
|
176 | - return ($this->curlInfo['http_code'] < 500 && $this->curlInfo['http_code'] >= 400); |
|
177 | - } |
|
178 | - |
|
179 | - public function isServerError() |
|
180 | - { |
|
181 | - return (500 <= $this->curlInfo['http_code'] && 600 > $this->curlInfo['http_code']); |
|
182 | - } |
|
109 | + public function getDescription () |
|
110 | + { |
|
111 | + return $this->getResponseObject()->description; |
|
112 | + } |
|
113 | + |
|
114 | + public function getHeaders() |
|
115 | + { |
|
116 | + return $this->headers; |
|
117 | + } |
|
118 | + |
|
119 | + public function getResponse() |
|
120 | + { |
|
121 | + return $this->body; |
|
122 | + } |
|
123 | + |
|
124 | + public function getResponseObject() |
|
125 | + { |
|
126 | + return json_decode($this->body); |
|
127 | + } |
|
128 | + |
|
129 | + public function getResponseArray () |
|
130 | + { |
|
131 | + return json_decode($this->body, true); |
|
132 | + } |
|
133 | + |
|
134 | + public function getResponseCode() |
|
135 | + { |
|
136 | + return $this->curlInfo['http_code']; |
|
137 | + } |
|
138 | + |
|
139 | + public function getReasonPhrase() |
|
140 | + { |
|
141 | + return $this->reasonPhrases[$this->curlInfo['http_code']]; |
|
142 | + } |
|
143 | + |
|
144 | + public function getContentType() |
|
145 | + { |
|
146 | + return $this->curlInfo['content_type']; |
|
147 | + } |
|
148 | + |
|
149 | + public function isOk() |
|
150 | + { |
|
151 | + return ($this->curlInfo['http_code'] === 200); |
|
152 | + } |
|
153 | + |
|
154 | + public function isSuccess() |
|
155 | + { |
|
156 | + return (200 <= $this->curlInfo['http_code'] && 300 > $this->curlInfo['http_code']); |
|
157 | + } |
|
158 | + |
|
159 | + public function isNotFound() |
|
160 | + { |
|
161 | + return ($this->curlInfo['http_code'] === 404); |
|
162 | + } |
|
163 | + |
|
164 | + public function isInformational() |
|
165 | + { |
|
166 | + return ($this->curlInfo['http_code'] >= 100 && $this->curlInfo['http_code'] < 200); |
|
167 | + } |
|
168 | + |
|
169 | + public function isRedirect() |
|
170 | + { |
|
171 | + return (300 <= $this->curlInfo['http_code'] && 400 > $this->curlInfo['http_code']); |
|
172 | + } |
|
173 | + |
|
174 | + public function isClientError() |
|
175 | + { |
|
176 | + return ($this->curlInfo['http_code'] < 500 && $this->curlInfo['http_code'] >= 400); |
|
177 | + } |
|
178 | + |
|
179 | + public function isServerError() |
|
180 | + { |
|
181 | + return (500 <= $this->curlInfo['http_code'] && 600 > $this->curlInfo['http_code']); |
|
182 | + } |
|
183 | 183 | |
184 | 184 | } |
@@ -25,13 +25,13 @@ |
||
25 | 25 | |
26 | 26 | interface ApiInterface |
27 | 27 | { |
28 | - public function get($url, $params = null, $headers = null); |
|
28 | + public function get($url, $params = null, $headers = null); |
|
29 | 29 | |
30 | - public function post($url, $params = null, $headers = null); |
|
30 | + public function post($url, $params = null, $headers = null); |
|
31 | 31 | |
32 | - public function delete($url, $params = null, $headers = null); |
|
32 | + public function delete($url, $params = null, $headers = null); |
|
33 | 33 | |
34 | - public function put($url, $params = null, $headers = null); |
|
34 | + public function put($url, $params = null, $headers = null); |
|
35 | 35 | |
36 | - public function patch($url, $params = null, $headers = null); |
|
36 | + public function patch($url, $params = null, $headers = null); |
|
37 | 37 | } |
@@ -28,112 +28,112 @@ |
||
28 | 28 | |
29 | 29 | class Bitlink { |
30 | 30 | |
31 | - private $url; |
|
32 | - private $api; |
|
31 | + private $url; |
|
32 | + private $api; |
|
33 | 33 | |
34 | - public function __construct (ApiInterface $api) |
|
35 | - { |
|
36 | - $this->api = $api; |
|
37 | - $this->url = 'https://api-ssl.bitly.com/v4'; |
|
38 | - } |
|
34 | + public function __construct (ApiInterface $api) |
|
35 | + { |
|
36 | + $this->api = $api; |
|
37 | + $this->url = 'https://api-ssl.bitly.com/v4'; |
|
38 | + } |
|
39 | 39 | |
40 | - /* |
|
40 | + /* |
|
41 | 41 | Get Metrics for a Bitlink by referrers by domain |
42 | 42 | https://dev.bitly.com/v4/#operation/getMetricsForBitlinkByReferrersByDomains |
43 | 43 | */ |
44 | - public function getMetricsForBitlinkByReferrersByDomains(string $bitlink, array $params = array()) |
|
45 | - { |
|
46 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers_by_domains', $params); |
|
47 | - } |
|
44 | + public function getMetricsForBitlinkByReferrersByDomains(string $bitlink, array $params = array()) |
|
45 | + { |
|
46 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers_by_domains', $params); |
|
47 | + } |
|
48 | 48 | |
49 | - /* |
|
49 | + /* |
|
50 | 50 | Get Metrics for a Bitlink by countries |
51 | 51 | https://dev.bitly.com/v4/#operation/getMetricsForBitlinkByCountries |
52 | 52 | */ |
53 | - public function getMetricsForBitlinkByCountries(string $bitlink, array $params = array()) |
|
54 | - { |
|
55 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/countries', $params); |
|
56 | - } |
|
53 | + public function getMetricsForBitlinkByCountries(string $bitlink, array $params = array()) |
|
54 | + { |
|
55 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/countries', $params); |
|
56 | + } |
|
57 | 57 | |
58 | - /* |
|
58 | + /* |
|
59 | 59 | Get Clicks for a Bitlink |
60 | 60 | https://dev.bitly.com/v4/#operation/getClicksForBitlink |
61 | 61 | */ |
62 | - public function getClicksForBitlink(string $bitlink, array $params = array()) |
|
63 | - { |
|
64 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks', $params); |
|
65 | - } |
|
62 | + public function getClicksForBitlink(string $bitlink, array $params = array()) |
|
63 | + { |
|
64 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks', $params); |
|
65 | + } |
|
66 | 66 | |
67 | - /* |
|
67 | + /* |
|
68 | 68 | Expand a Bitlink |
69 | 69 | https://dev.bitly.com/v4/#operation/expandBitlink |
70 | 70 | */ |
71 | - public function expandBitlink(array $params) |
|
72 | - { |
|
73 | - return $this->api->post($this->url . '/expand', $params); |
|
74 | - } |
|
71 | + public function expandBitlink(array $params) |
|
72 | + { |
|
73 | + return $this->api->post($this->url . '/expand', $params); |
|
74 | + } |
|
75 | 75 | |
76 | - /* |
|
76 | + /* |
|
77 | 77 | Get Metrics for a Bitlink by referrers |
78 | 78 | https://dev.bitly.com/v4/#operation/getMetricsForBitlinkByReferrers |
79 | 79 | */ |
80 | - public function getMetricsForBitlinkByReferrers(string $bitlink, array $params = array()) |
|
81 | - { |
|
82 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers', $params); |
|
83 | - } |
|
80 | + public function getMetricsForBitlinkByReferrers(string $bitlink, array $params = array()) |
|
81 | + { |
|
82 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referrers', $params); |
|
83 | + } |
|
84 | 84 | |
85 | - /* |
|
85 | + /* |
|
86 | 86 | Create a Bitlink |
87 | 87 | https://dev.bitly.com/v4/#operation/createFullBitlink |
88 | 88 | */ |
89 | - public function createFullBitlink(array $params) |
|
90 | - { |
|
91 | - return $this->api->post($this->url . '/bitlinks', $params); |
|
92 | - } |
|
89 | + public function createFullBitlink(array $params) |
|
90 | + { |
|
91 | + return $this->api->post($this->url . '/bitlinks', $params); |
|
92 | + } |
|
93 | 93 | |
94 | - /* |
|
94 | + /* |
|
95 | 95 | Update a Bitlink |
96 | 96 | https://dev.bitly.com/v4/#operation/updateBitlink |
97 | 97 | */ |
98 | - public function updateBitlink(string $bitlink, array $params) |
|
99 | - { |
|
100 | - return $this->api->patch($this->url . '/bitlinks/'.$bitlink, $params); |
|
101 | - } |
|
98 | + public function updateBitlink(string $bitlink, array $params) |
|
99 | + { |
|
100 | + return $this->api->patch($this->url . '/bitlinks/'.$bitlink, $params); |
|
101 | + } |
|
102 | 102 | |
103 | - /* |
|
103 | + /* |
|
104 | 104 | Retrieve a Bitlink |
105 | 105 | https://dev.bitly.com/v4/#operation/getBitlink |
106 | 106 | */ |
107 | - public function getBitlink(string $bitlink) |
|
108 | - { |
|
109 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink); |
|
110 | - } |
|
107 | + public function getBitlink(string $bitlink) |
|
108 | + { |
|
109 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink); |
|
110 | + } |
|
111 | 111 | |
112 | - /* |
|
112 | + /* |
|
113 | 113 | Get Clicks Summary for a Bitlink |
114 | 114 | https://dev.bitly.com/v4/#operation/getClicksSummaryForBitlink |
115 | 115 | */ |
116 | - public function getClicksSummaryForBitlink(string $bitlink, array $params = array()) |
|
117 | - { |
|
118 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks/summary', $params); |
|
119 | - } |
|
116 | + public function getClicksSummaryForBitlink(string $bitlink, array $params = array()) |
|
117 | + { |
|
118 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/clicks/summary', $params); |
|
119 | + } |
|
120 | 120 | |
121 | - /* |
|
121 | + /* |
|
122 | 122 | Shorten a Link |
123 | 123 | https://dev.bitly.com/v4/#operation/createBitlink |
124 | 124 | */ |
125 | - public function createBitlink(array $params) |
|
126 | - { |
|
127 | - return $this->api->post($this->url . '/shorten', $params); |
|
128 | - } |
|
125 | + public function createBitlink(array $params) |
|
126 | + { |
|
127 | + return $this->api->post($this->url . '/shorten', $params); |
|
128 | + } |
|
129 | 129 | |
130 | - /* |
|
130 | + /* |
|
131 | 131 | Get Metrics for a Bitlink by referring domains |
132 | 132 | https://dev.bitly.com/v4/#operation/getMetricsForBitlinkByReferringDomains |
133 | 133 | */ |
134 | - public function getMetricsForBitlinkByReferringDomains(string $bitlink, array $params = array()) |
|
135 | - { |
|
136 | - return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referring_domains', $params); |
|
137 | - } |
|
134 | + public function getMetricsForBitlinkByReferringDomains(string $bitlink, array $params = array()) |
|
135 | + { |
|
136 | + return $this->api->get($this->url . '/bitlinks/'.$bitlink.'/referring_domains', $params); |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
@@ -28,31 +28,31 @@ |
||
28 | 28 | |
29 | 29 | class User { |
30 | 30 | |
31 | - private $url; |
|
32 | - private $api; |
|
31 | + private $url; |
|
32 | + private $api; |
|
33 | 33 | |
34 | - public function __construct (ApiInterface $api) |
|
35 | - { |
|
36 | - $this->api = $api; |
|
37 | - $this->url = 'https://api-ssl.bitly.com/v4/user'; |
|
38 | - } |
|
34 | + public function __construct (ApiInterface $api) |
|
35 | + { |
|
36 | + $this->api = $api; |
|
37 | + $this->url = 'https://api-ssl.bitly.com/v4/user'; |
|
38 | + } |
|
39 | 39 | |
40 | - /* |
|
40 | + /* |
|
41 | 41 | Update a User |
42 | 42 | https://dev.bitly.com/v4/#operation/updateUser |
43 | 43 | */ |
44 | - public function updateUser(array $params) |
|
45 | - { |
|
46 | - return $this->api->patch($this->url, $params); |
|
47 | - } |
|
44 | + public function updateUser(array $params) |
|
45 | + { |
|
46 | + return $this->api->patch($this->url, $params); |
|
47 | + } |
|
48 | 48 | |
49 | - /* |
|
49 | + /* |
|
50 | 50 | Retrieve a User |
51 | 51 | https://dev.bitly.com/v4/#operation/getUser |
52 | 52 | */ |
53 | - public function getUser() |
|
54 | - { |
|
55 | - return $this->api->get($this->url); |
|
56 | - } |
|
53 | + public function getUser() |
|
54 | + { |
|
55 | + return $this->api->get($this->url); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | } |
@@ -28,37 +28,37 @@ |
||
28 | 28 | |
29 | 29 | class Auth { |
30 | 30 | |
31 | - private $url; |
|
32 | - private $api; |
|
31 | + private $url; |
|
32 | + private $api; |
|
33 | 33 | |
34 | - public function __construct (ApiInterface $api, array $config) |
|
35 | - { |
|
36 | - $this->api = $api; |
|
37 | - $this->url = 'https://api-ssl.bitly.com/oauth/access_token'; |
|
38 | - $key = base64_encode($config['clientid_username'].":".$config['clientsecret_password']); |
|
39 | - $api->setApiKey($key); |
|
40 | - } |
|
34 | + public function __construct (ApiInterface $api, array $config) |
|
35 | + { |
|
36 | + $this->api = $api; |
|
37 | + $this->url = 'https://api-ssl.bitly.com/oauth/access_token'; |
|
38 | + $key = base64_encode($config['clientid_username'].":".$config['clientsecret_password']); |
|
39 | + $api->setApiKey($key); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /* |
|
43 | + /* |
|
44 | 44 | Exchanging a Username and Password for an Access Token |
45 | 45 | https://dev.bitly.com/v4/#section/Exchanging-a-Username-and-Password-for-an-Access-Token |
46 | 46 | */ |
47 | - public function exchangeToken(array $params) |
|
48 | - { |
|
49 | - $params['grant_type'] = 'password'; |
|
50 | - $result = $this->api->post($this->url, $params); |
|
51 | - return json_decode($result->getResponse(), true)['access_token']; |
|
52 | - } |
|
47 | + public function exchangeToken(array $params) |
|
48 | + { |
|
49 | + $params['grant_type'] = 'password'; |
|
50 | + $result = $this->api->post($this->url, $params); |
|
51 | + return json_decode($result->getResponse(), true)['access_token']; |
|
52 | + } |
|
53 | 53 | |
54 | - /* |
|
54 | + /* |
|
55 | 55 | HTTP Basic Authentication Flow |
56 | 56 | https://dev.bitly.com/v4/#section/HTTP-Basic-Authentication-Flow |
57 | 57 | */ |
58 | - public function basicAuthFlow(array $params) |
|
59 | - { |
|
60 | - $result = $this->api->post($this->url, $params); |
|
61 | - return $result->getResponse(); |
|
62 | - } |
|
58 | + public function basicAuthFlow(array $params) |
|
59 | + { |
|
60 | + $result = $this->api->post($this->url, $params); |
|
61 | + return $result->getResponse(); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | } |
@@ -28,40 +28,40 @@ |
||
28 | 28 | |
29 | 29 | class Organization { |
30 | 30 | |
31 | - private $url; |
|
32 | - private $api; |
|
31 | + private $url; |
|
32 | + private $api; |
|
33 | 33 | |
34 | - public function __construct (ApiInterface $api) |
|
35 | - { |
|
36 | - $this->api = $api; |
|
37 | - $this->url = 'https://api-ssl.bitly.com/v4/organizations'; |
|
38 | - } |
|
34 | + public function __construct (ApiInterface $api) |
|
35 | + { |
|
36 | + $this->api = $api; |
|
37 | + $this->url = 'https://api-ssl.bitly.com/v4/organizations'; |
|
38 | + } |
|
39 | 39 | |
40 | - /* |
|
40 | + /* |
|
41 | 41 | Retrieve Organizations |
42 | 42 | https://dev.bitly.com/v4/#operation/getOrganizations |
43 | 43 | */ |
44 | - public function getOrganizations() |
|
45 | - { |
|
46 | - return $this->api->get($this->url); |
|
47 | - } |
|
44 | + public function getOrganizations() |
|
45 | + { |
|
46 | + return $this->api->get($this->url); |
|
47 | + } |
|
48 | 48 | |
49 | - /* |
|
49 | + /* |
|
50 | 50 | Retrieve Organization Shorten Counts |
51 | 51 | https://dev.bitly.com/v4/#operation/getOrganizationShortenCounts |
52 | 52 | */ |
53 | - public function getOrganizationShortenCounts(string $organization_guid) |
|
54 | - { |
|
55 | - return $this->api->get($this->url . '/'.$organization_guid.'/shorten_counts'); |
|
56 | - } |
|
53 | + public function getOrganizationShortenCounts(string $organization_guid) |
|
54 | + { |
|
55 | + return $this->api->get($this->url . '/'.$organization_guid.'/shorten_counts'); |
|
56 | + } |
|
57 | 57 | |
58 | - /* |
|
58 | + /* |
|
59 | 59 | Retrieve an Organization |
60 | 60 | https://dev.bitly.com/v4/#operation/getOrganization |
61 | 61 | */ |
62 | - public function getOrganization(string $organization_guid) |
|
63 | - { |
|
64 | - return $this->api->get($this->url . '/'.$organization_guid); |
|
65 | - } |
|
62 | + public function getOrganization(string $organization_guid) |
|
63 | + { |
|
64 | + return $this->api->get($this->url . '/'.$organization_guid); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | } |
@@ -28,85 +28,85 @@ |
||
28 | 28 | |
29 | 29 | class Campaign { |
30 | 30 | |
31 | - private $url; |
|
32 | - private $api; |
|
31 | + private $url; |
|
32 | + private $api; |
|
33 | 33 | |
34 | - public function __construct (ApiInterface $api) |
|
35 | - { |
|
36 | - $this->api = $api; |
|
37 | - $this->url = 'https://api-ssl.bitly.com/v4'; |
|
38 | - } |
|
34 | + public function __construct (ApiInterface $api) |
|
35 | + { |
|
36 | + $this->api = $api; |
|
37 | + $this->url = 'https://api-ssl.bitly.com/v4'; |
|
38 | + } |
|
39 | 39 | |
40 | - /* |
|
40 | + /* |
|
41 | 41 | Create Channel |
42 | 42 | https://dev.bitly.com/v4/#operation/createChannel |
43 | 43 | */ |
44 | - public function createChannel(array $params) |
|
45 | - { |
|
46 | - return $this->api->post($this->url . '/channels', $params); |
|
47 | - } |
|
44 | + public function createChannel(array $params) |
|
45 | + { |
|
46 | + return $this->api->post($this->url . '/channels', $params); |
|
47 | + } |
|
48 | 48 | |
49 | - /* |
|
49 | + /* |
|
50 | 50 | Retrieve Channels |
51 | 51 | https://dev.bitly.com/v4/#operation/getChannels |
52 | 52 | */ |
53 | - public function getChannels(array $params) |
|
54 | - { |
|
55 | - return $this->api->get($this->url . '/channels', $params); |
|
56 | - } |
|
53 | + public function getChannels(array $params) |
|
54 | + { |
|
55 | + return $this->api->get($this->url . '/channels', $params); |
|
56 | + } |
|
57 | 57 | |
58 | - /* |
|
58 | + /* |
|
59 | 59 | Create Campaign |
60 | 60 | https://dev.bitly.com/v4/#operation/createCampaign |
61 | 61 | */ |
62 | - public function createCampaign(array $params) |
|
63 | - { |
|
64 | - return $this->api->post($this->url . '/campaigns', $params); |
|
65 | - } |
|
62 | + public function createCampaign(array $params) |
|
63 | + { |
|
64 | + return $this->api->post($this->url . '/campaigns', $params); |
|
65 | + } |
|
66 | 66 | |
67 | - /* |
|
67 | + /* |
|
68 | 68 | Retrieve Campaigns |
69 | 69 | https://dev.bitly.com/v4/#operation/getCampaigns |
70 | 70 | */ |
71 | - public function getCampaigns(array $params) |
|
72 | - { |
|
73 | - return $this->api->get($this->url . '/campaigns', $params); |
|
74 | - } |
|
71 | + public function getCampaigns(array $params) |
|
72 | + { |
|
73 | + return $this->api->get($this->url . '/campaigns', $params); |
|
74 | + } |
|
75 | 75 | |
76 | - /* |
|
76 | + /* |
|
77 | 77 | Retrieve a Campaign |
78 | 78 | https://dev.bitly.com/v4/#operation/getCampaign |
79 | 79 | */ |
80 | - public function getCampaign(string $campaign_guid) |
|
81 | - { |
|
82 | - return $this->api->get($this->url . '/campaigns/'.$campaign_guid); |
|
83 | - } |
|
80 | + public function getCampaign(string $campaign_guid) |
|
81 | + { |
|
82 | + return $this->api->get($this->url . '/campaigns/'.$campaign_guid); |
|
83 | + } |
|
84 | 84 | |
85 | - /* |
|
85 | + /* |
|
86 | 86 | Update Campaign |
87 | 87 | https://dev.bitly.com/v4/#operation/updateCampaign |
88 | 88 | */ |
89 | - public function updateCampaign(string $campaign_guid, array $params) |
|
90 | - { |
|
91 | - return $this->api->patch($this->url . '/campaigns/'.$campaign_guid, $params); |
|
92 | - } |
|
89 | + public function updateCampaign(string $campaign_guid, array $params) |
|
90 | + { |
|
91 | + return $this->api->patch($this->url . '/campaigns/'.$campaign_guid, $params); |
|
92 | + } |
|
93 | 93 | |
94 | - /* |
|
94 | + /* |
|
95 | 95 | Get A Channel |
96 | 96 | https://dev.bitly.com/v4/#operation/getChannel |
97 | 97 | */ |
98 | - public function getChannel(string $channel_guid) |
|
99 | - { |
|
100 | - return $this->api->get($this->url . '/channels/'.$channel_guid); |
|
101 | - } |
|
98 | + public function getChannel(string $channel_guid) |
|
99 | + { |
|
100 | + return $this->api->get($this->url . '/channels/'.$channel_guid); |
|
101 | + } |
|
102 | 102 | |
103 | - /* |
|
103 | + /* |
|
104 | 104 | Update A Channel |
105 | 105 | https://dev.bitly.com/v4/#operation/updateChannel |
106 | 106 | */ |
107 | - public function updateChannel(string $channel_guid, array $params) |
|
108 | - { |
|
109 | - return $this->api->patch($this->url . '/channels/'.$channel_guid, $params); |
|
110 | - } |
|
107 | + public function updateChannel(string $channel_guid, array $params) |
|
108 | + { |
|
109 | + return $this->api->patch($this->url . '/channels/'.$channel_guid, $params); |
|
110 | + } |
|
111 | 111 | |
112 | 112 | } |
@@ -28,121 +28,121 @@ |
||
28 | 28 | |
29 | 29 | class Group { |
30 | 30 | |
31 | - private $url; |
|
32 | - private $api; |
|
31 | + private $url; |
|
32 | + private $api; |
|
33 | 33 | |
34 | - public function __construct (ApiInterface $api) |
|
35 | - { |
|
36 | - $this->api = $api; |
|
37 | - $this->url = 'https://api-ssl.bitly.com/v4/groups'; |
|
38 | - } |
|
34 | + public function __construct (ApiInterface $api) |
|
35 | + { |
|
36 | + $this->api = $api; |
|
37 | + $this->url = 'https://api-ssl.bitly.com/v4/groups'; |
|
38 | + } |
|
39 | 39 | |
40 | - /* |
|
40 | + /* |
|
41 | 41 | Retrieve Tags by Group |
42 | 42 | https://dev.bitly.com/v4/#operation/getGroupTags |
43 | 43 | */ |
44 | - public function getGroupTags(string $group_guid) |
|
45 | - { |
|
46 | - return $this->api->get($this->url . '/'.$group_guid.'/tags'); |
|
47 | - } |
|
44 | + public function getGroupTags(string $group_guid) |
|
45 | + { |
|
46 | + return $this->api->get($this->url . '/'.$group_guid.'/tags'); |
|
47 | + } |
|
48 | 48 | |
49 | - /* |
|
49 | + /* |
|
50 | 50 | Get Click Metrics for a Group by referring networks |
51 | 51 | https://dev.bitly.com/v4/#operation/GetGroupMetricsByReferringNetworks |
52 | 52 | */ |
53 | - public function getGroupMetricsByReferringNetworks(string $group_guid) |
|
54 | - { |
|
55 | - return $this->api->get($this->url . '/'.$group_guid.'/referring_networks'); |
|
56 | - } |
|
53 | + public function getGroupMetricsByReferringNetworks(string $group_guid) |
|
54 | + { |
|
55 | + return $this->api->get($this->url . '/'.$group_guid.'/referring_networks'); |
|
56 | + } |
|
57 | 57 | |
58 | - /* |
|
58 | + /* |
|
59 | 59 | Retrieve Group Shorten Counts |
60 | 60 | https://dev.bitly.com/v4/#operation/getGroupShortenCounts |
61 | 61 | */ |
62 | - public function getGroupShortenCounts(string $group_guid) |
|
63 | - { |
|
64 | - return $this->api->get($this->url . '/'.$group_guid.'/shorten_counts'); |
|
65 | - } |
|
62 | + public function getGroupShortenCounts(string $group_guid) |
|
63 | + { |
|
64 | + return $this->api->get($this->url . '/'.$group_guid.'/shorten_counts'); |
|
65 | + } |
|
66 | 66 | |
67 | - /* |
|
67 | + /* |
|
68 | 68 | Retrieve Groups |
69 | 69 | https://dev.bitly.com/v4/#operation/getGroups |
70 | 70 | */ |
71 | - public function getGroups(array $params = array()) |
|
72 | - { |
|
73 | - return $this->api->get($this->url, $params); |
|
74 | - } |
|
71 | + public function getGroups(array $params = array()) |
|
72 | + { |
|
73 | + return $this->api->get($this->url, $params); |
|
74 | + } |
|
75 | 75 | |
76 | - /* |
|
76 | + /* |
|
77 | 77 | Retrieve Group Preferences |
78 | 78 | https://dev.bitly.com/v4/#operation/getGroupPreferences |
79 | 79 | */ |
80 | - public function getGroupPreferences(string $group_guid) |
|
81 | - { |
|
82 | - return $this->api->get($this->url . '/'.$group_guid.'/preferences'); |
|
83 | - } |
|
80 | + public function getGroupPreferences(string $group_guid) |
|
81 | + { |
|
82 | + return $this->api->get($this->url . '/'.$group_guid.'/preferences'); |
|
83 | + } |
|
84 | 84 | |
85 | - /* |
|
85 | + /* |
|
86 | 86 | Update Group Preferences |
87 | 87 | https://dev.bitly.com/v4/#operation/updateGroupPreferences |
88 | 88 | */ |
89 | - public function updateGroupPreferences(string $group_guid, array $params) |
|
90 | - { |
|
91 | - return $this->api->patch($this->url . '/'.$group_guid.'/preferences', $params); |
|
92 | - } |
|
89 | + public function updateGroupPreferences(string $group_guid, array $params) |
|
90 | + { |
|
91 | + return $this->api->patch($this->url . '/'.$group_guid.'/preferences', $params); |
|
92 | + } |
|
93 | 93 | |
94 | - /* |
|
94 | + /* |
|
95 | 95 | Retrieve Bitlinks by Group |
96 | 96 | https://dev.bitly.com/v4/#operation/getBitlinksByGroup |
97 | 97 | */ |
98 | - public function getBitlinksByGroup(string $group_guid, array $params = array()) |
|
99 | - { |
|
100 | - return $this->api->get($this->url . '/'.$group_guid.'/bitlinks', $params); |
|
101 | - } |
|
98 | + public function getBitlinksByGroup(string $group_guid, array $params = array()) |
|
99 | + { |
|
100 | + return $this->api->get($this->url . '/'.$group_guid.'/bitlinks', $params); |
|
101 | + } |
|
102 | 102 | |
103 | - /* |
|
103 | + /* |
|
104 | 104 | Get Click Metrics for a Group by countries |
105 | 105 | https://dev.bitly.com/v4/#operation/getGroupMetricsByCountries |
106 | 106 | */ |
107 | - public function getGroupMetricsByCountries(string $group_guid) |
|
108 | - { |
|
109 | - return $this->api->get($this->url . '/'.$group_guid.'/countries'); |
|
110 | - } |
|
107 | + public function getGroupMetricsByCountries(string $group_guid) |
|
108 | + { |
|
109 | + return $this->api->get($this->url . '/'.$group_guid.'/countries'); |
|
110 | + } |
|
111 | 111 | |
112 | - /* |
|
112 | + /* |
|
113 | 113 | Retrieve Sorted Bitlinks for Group |
114 | 114 | https://dev.bitly.com/v4/#operation/getSortedBitlinks |
115 | 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 | - } |
|
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 | 120 | |
121 | - /* |
|
121 | + /* |
|
122 | 122 | Update a Group |
123 | 123 | https://dev.bitly.com/v4/#operation/updateGroup |
124 | 124 | */ |
125 | - public function updateGroup(string $group_guid, array $params) |
|
126 | - { |
|
127 | - return $this->api->patch($this->url . '/'.$group_guid, $params); |
|
128 | - } |
|
125 | + public function updateGroup(string $group_guid, array $params) |
|
126 | + { |
|
127 | + return $this->api->patch($this->url . '/'.$group_guid, $params); |
|
128 | + } |
|
129 | 129 | |
130 | - /* |
|
130 | + /* |
|
131 | 131 | Retrieve a Group |
132 | 132 | https://dev.bitly.com/v4/#operation/getGroup |
133 | 133 | */ |
134 | - public function getGroup(string $group_guid) |
|
135 | - { |
|
136 | - return $this->api->get($this->url . '/'.$group_guid); |
|
137 | - } |
|
134 | + public function getGroup(string $group_guid) |
|
135 | + { |
|
136 | + return $this->api->get($this->url . '/'.$group_guid); |
|
137 | + } |
|
138 | 138 | |
139 | - /* |
|
139 | + /* |
|
140 | 140 | Delete a Group |
141 | 141 | https://dev.bitly.com/v4/#operation/deleteGroup |
142 | 142 | */ |
143 | - public function deleteGroup(string $group_guid) |
|
144 | - { |
|
145 | - return $this->api->delete($this->url . '/'.$group_guid); |
|
146 | - } |
|
143 | + public function deleteGroup(string $group_guid) |
|
144 | + { |
|
145 | + return $this->api->delete($this->url . '/'.$group_guid); |
|
146 | + } |
|
147 | 147 | |
148 | 148 | } |
@@ -28,49 +28,49 @@ |
||
28 | 28 | |
29 | 29 | class Custom { |
30 | 30 | |
31 | - private $url; |
|
32 | - private $api; |
|
31 | + private $url; |
|
32 | + private $api; |
|
33 | 33 | |
34 | - public function __construct (ApiInterface $api) |
|
35 | - { |
|
36 | - $this->api = $api; |
|
37 | - $this->url = 'https://api-ssl.bitly.com/v4/custom_bitlinks'; |
|
38 | - } |
|
34 | + public function __construct (ApiInterface $api) |
|
35 | + { |
|
36 | + $this->api = $api; |
|
37 | + $this->url = 'https://api-ssl.bitly.com/v4/custom_bitlinks'; |
|
38 | + } |
|
39 | 39 | |
40 | - /* |
|
40 | + /* |
|
41 | 41 | Update Custom Bitlink |
42 | 42 | https://dev.bitly.com/v4/#operation/updateCustomBitlink |
43 | 43 | */ |
44 | - public function updateCustomBitlink(string $custom_bitlink, array $params) |
|
45 | - { |
|
46 | - return $this->api->patch($this->url . '/'.$custom_bitlink, $params); |
|
47 | - } |
|
44 | + public function updateCustomBitlink(string $custom_bitlink, array $params) |
|
45 | + { |
|
46 | + return $this->api->patch($this->url . '/'.$custom_bitlink, $params); |
|
47 | + } |
|
48 | 48 | |
49 | - /* |
|
49 | + /* |
|
50 | 50 | Retrieve Custom Bitlink |
51 | 51 | https://dev.bitly.com/v4/#operation/getCustomBitlink |
52 | 52 | */ |
53 | - public function getCustomBitlink(string $custom_bitlink) |
|
54 | - { |
|
55 | - return $this->api->get($this->url . '/'.$custom_bitlink); |
|
56 | - } |
|
53 | + public function getCustomBitlink(string $custom_bitlink) |
|
54 | + { |
|
55 | + return $this->api->get($this->url . '/'.$custom_bitlink); |
|
56 | + } |
|
57 | 57 | |
58 | - /* |
|
58 | + /* |
|
59 | 59 | Add Custom Bitlink |
60 | 60 | https://dev.bitly.com/v4/#operation/addCustomBitlink |
61 | 61 | */ |
62 | - public function addCustomBitlink(array $params) |
|
63 | - { |
|
64 | - return $this->api->post($this->url, $params); |
|
65 | - } |
|
62 | + public function addCustomBitlink(array $params) |
|
63 | + { |
|
64 | + return $this->api->post($this->url, $params); |
|
65 | + } |
|
66 | 66 | |
67 | - /* |
|
67 | + /* |
|
68 | 68 | Get Metrics for a Custom Bitlink by destination |
69 | 69 | https://dev.bitly.com/v4/#operation/getCustomBitlinkMetricsByDestination |
70 | 70 | */ |
71 | - public function getCustomBitlinkMetricsByDestination(string $custom_bitlink) |
|
72 | - { |
|
73 | - return $this->api->get($this->url . '/'.$custom_bitlink.'/clicks_by_destination'); |
|
74 | - } |
|
71 | + public function getCustomBitlinkMetricsByDestination(string $custom_bitlink) |
|
72 | + { |
|
73 | + return $this->api->get($this->url . '/'.$custom_bitlink.'/clicks_by_destination'); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | } |