php-guzzleHow to add an application/x-www-form-urlencoded header in PHP Guzzle?
Adding an application/x-www-form-urlencoded header in PHP Guzzle can be done using the setHeader method.
Example code
$client = new \GuzzleHttp\Client();
$client->setHeader('Content-Type', 'application/x-www-form-urlencoded');
The code above creates a new Guzzle client and sets the header Content-Type to application/x-www-form-urlencoded.
Code explanation
$client = new \GuzzleHttp\Client();- creates a new Guzzle client$client->setHeader('Content-Type', 'application/x-www-form-urlencoded');- sets the headerContent-Typetoapplication/x-www-form-urlencoded
Helpful links
More of Php Guzzle
- How to set a user agent in PHP Guzzle?
- How to install PHP Guzzle without Composer?
- How to stream with PHP Guzzle?
- How to handle a RequestException with PHP Guzzle?
- How to use PHP Guzzle to make a batch request?
- How to add an SSL certificate to a request with PHP Guzzle?
- How to use cookies with Guzzle in PHP?
- How to convert a response to an array with PHP Guzzle?
- How to send multiple requests with Guzzle in PHP?
- How to use form_params with PHP Guzzle?
See more codes...