@@ -28,36 +28,36 @@ |
||
| 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 | Exchanging a Username and Password for an Access Token |
| 44 | 44 | https://dev.bitly.com/docs/getting-started/authentication |
| 45 | 45 | */ |
| 46 | - public function exchangeToken(array $params) |
|
| 47 | - { |
|
| 48 | - $params['grant_type'] = 'password'; |
|
| 49 | - $result = $this->api->post($this->url, $params); |
|
| 50 | - return json_decode($result->getResponse(), true)['access_token']; |
|
| 51 | - } |
|
| 46 | + public function exchangeToken(array $params) |
|
| 47 | + { |
|
| 48 | + $params['grant_type'] = 'password'; |
|
| 49 | + $result = $this->api->post($this->url, $params); |
|
| 50 | + return json_decode($result->getResponse(), true)['access_token']; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /* |
|
| 53 | + /* |
|
| 54 | 54 | HTTP Basic Authentication Flow |
| 55 | 55 | https://dev.bitly.com/docs/getting-started/authentication |
| 56 | 56 | */ |
| 57 | - public function basicAuthFlow(array $params) |
|
| 58 | - { |
|
| 59 | - $result = $this->api->post($this->url, $params); |
|
| 60 | - return $result->getResponse(); |
|
| 61 | - } |
|
| 57 | + public function basicAuthFlow(array $params) |
|
| 58 | + { |
|
| 59 | + $result = $this->api->post($this->url, $params); |
|
| 60 | + return $result->getResponse(); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | } |