根据
the manual,
The body option is used to control the body of an entity enclosing
request (e.g., PUT, POST, PATCH).
记录的put’ing方法是:
$client = new GuzzleHttp\Client();
$client->put('http://httpbin.org', [
'headers' => ['X-Foo' => 'Bar'],
'body' => [
'field' => 'abc',
'other_field' => '123'
],
'allow_redirects' => false,
'timeout' => 5
]);
编辑
根据您的评论:
您缺少createRequest函数的第三个参数 – 构成post或put数据的键/值对数组:
$request = $client->createRequest('PUT', '/put', ['body' => ['foo' => 'bar']]);