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 use Monolog with Guzzle in PHP?
- How to install PHP Guzzle without Composer?
- How to mock requests with Guzzle in PHP?
- How to add a bearer token in PHP Guzzle?
- How to make HTTP2 request with PHP Guzzle?
- How to stream with PHP Guzzle?
- How to set a timeout for a request 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?
See more codes...