| Conditions | 2 |
| Paths | 2 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 21 | public static function getApiKey($username, $password) |
||
| 22 | { |
||
| 23 | $client = new GuzzleHttpClient(['cookies' => true, 'allow_redirects' => false]); |
||
| 24 | $client->post( |
||
| 25 | 'https://panel.kontakt.io/signin', |
||
| 26 | [ |
||
| 27 | 'form_params' => [ |
||
| 28 | 'username' => $username, |
||
| 29 | 'password' => $password, |
||
| 30 | ], |
||
| 31 | ] |
||
| 32 | ); |
||
| 33 | |||
| 34 | $response = $client->get('https://panel.kontakt.io/api-key'); |
||
| 35 | |||
| 36 | if ($response->getStatusCode() !== 200) { |
||
| 37 | throw new ApiKeyExtractionInvalidCredentialsException(); |
||
| 38 | } |
||
| 39 | |||
| 40 | return (string)$response->getBody(); |
||
| 41 | } |
||
| 42 | |||
| 60 |