我正在尝试使用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),
]
]);
使用这种语法我得到它woking ..