草庐IT

php - Laravel 中的 Guzzle 客户端 : InvalidArgumentException: "No method is configured to handle the form_params config key"

coder 2024-04-28 原文

我正在尝试使用 Guzzle 客户端向 API 发送请求,但收到一条错误消息,

InvalidArgumentException: "No method is configured to handle the form_params config key"

这是我试过的:

$response = $this->guzzle->post("https://example.com",[
                'form_params'=> [
                    'client_id'=>$this->client_id,
                    'authorization_code'=>$this->authorization_code,
                    'decoder_query'=> $this->requestQuery
                  ],
            ]
        );

$this->requestQuery 是一个 JSON 请求。

最佳答案

$response = $this->guzzle->post("https://example.com", [
    'body' => [
        'client_id'         => $this->client_id,
        'authorization_code'=> $this->authorization_code,
        'decoder_query'     => json_encode($this->requestQuery),
    ]
]);

有了这个语法我就明白了..

关于php - Laravel 中的 Guzzle 客户端 : InvalidArgumentException: "No method is configured to handle the form_params config key",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30674089/

有关php - Laravel 中的 Guzzle 客户端 : InvalidArgumentException: "No method is configured to handle the form_params config key"的更多相关文章

随机推荐