如何使用Guzzle发布数组字段?我尝试了以下内容,但fruits
变量中没有收到任何内容。
$fruits = ['apple', 'orange', 'banana'];
$client = new \GuzzleHttp\Client();
$response = $client->post('http://example/post', [
'form_params' => [ 'fruits' => $fruits ]
] );
答案 0 :(得分:0)
你可以试试这个
$fruits = ['apple', 'orange', 'banana'];
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', http://example/post, [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded'
],
'form_params' => $fruits
]);