Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Oauth2Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,15 @@ protected function _post($url, $params = array(), $headers = array(), $auth = ar

$postOptions['verify'] = false;

$res = $client->request('post', $url, $postOptions);
try {
$res = $client->request('post', $url, $postOptions);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$response = $e->getResponse();
$responseBodyAsString = $response->getBody()->getContents();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, will there alway be response body and content?

return json_decode($responseBodyAsString);
} catch (\Exception $e) {
return json_encode($e->getMessage());
}

//echo $res->getStatusCode(); // "200"
//echo $res->getHeader('content-type'); // 'application/json; charset=utf8'
Expand All @@ -329,6 +337,10 @@ protected function _get($url)
'Content-type' => 'application/json'
)
));
} catch (\GuzzleHttp\Exception\ClientException $e) {
$response = $e->getResponse();
$responseBodyAsString = $response->getBody()->getContents();
return json_decode($responseBodyAsString);
} catch (\Exception $e) {
return json_encode($e->getMessage());
}
Expand Down