【问题标题】:How to Retrieve Form Parameters sent on a Guzzle Exception?如何检索在 Guzzle 异常上发送的表单参数?
【发布时间】:2020-07-15 02:30:23
【问题描述】:

如何从 Guzzle 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 guzzle6 guzzle


【解决方案1】:

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

try {
    $reponse = $this->client->post($uri, [
        'form_params' => $params,
        'headers' => $this->getHeaders()
    ]);
} catch (RequestException $e){
     echo (string) $e->getRequest()->getBody();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-09
    • 1970-01-01
    • 2019-11-16
    • 2015-03-25
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多