【发布时间】:2013-11-13 21:55:43
【问题描述】:
当服务器返回 4xx 和 5xx 状态代码时,我想处理来自 Guzzle 的错误。我提出这样的要求:
$client = $this->getGuzzleClient();
$request = $client->post($url, $headers, $value);
try {
$response = $request->send();
return $response->getBody();
} catch (\Exception $e) {
// How can I get the response body?
}
$e->getMessage 返回代码信息,但不返回 HTTP 响应的正文。如何获取响应正文?
【问题讨论】:
-
这个问题与stackoverflow.com/questions/17658283/…这个问题有关,那里的答案也可能有一些帮助。