如何检索在异常情况下发送的表单参数?

问题描述 投票:0回答:1

如何检索从枪口BadResponseException(ClientException || ServerException)对象使用的form_params?

我在文档中找不到它。

try {
    $reponse = $this->client->post($uri, [
        'form_params' => $params,
        'headers' => $this->getHeaders()
    ]);
} catch (RequestException $e){
     /// get form_params here without accessing $params
}
php exception guzzle guzzle6 guzzlehttp
1个回答
0
投票

表单编码参数可以在请求正文中找到。

try {
    $reponse = $this->client->post($uri, [
        'form_params' => $params,
        'headers' => $this->getHeaders()
    ]);
} catch (RequestException $e){
     echo (string) $e->getRequest()->getBody();
}
© www.soinside.com 2019 - 2024. All rights reserved.