根據
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']]);