body
Summary
: The body option is used to control the body of an entityenclosing request (e.g., PUT, POST, PATCH).
Types
: - string
- fopen() resource
- Psr\Http\Message\StreamInterface
Default : None
Constant
: GuzzleHttp\RequestOptions::BODY
This setting can be set to any of the following types:- string
1. // You can send requests that use a string as the message body.
2. $client->request('PUT', '/put', ['body' => 'foo']);
- resource returned from
fopen()
1. // You can send requests that use a stream resource as the body.
2. $resource = fopen('http://httpbin.org', 'r');
3. $client->request('PUT', '/put', ['body' => $resource]);
Psr\Http\Message\StreamInterface
1. // You can send requests that use a Guzzle stream object as the body
2. $stream = GuzzleHttp\Psr7\stream_for('contents...');
3. $client->request('POST', '/post', ['body' => $stream]);
Note
This option cannot be used with form_params, multipart, or json
