I'm trying to set the referer header on a guzzle request, but when I analyze the request Chrome developer tools, the referer header is not in the list of request headers. This is how I set the header:
$headers = ['referer' => 'test.referer.com'];
$guzzle = new Client([
'defaults' => ['headers' => $headers]
]);
$result = $guzzle->get('http://google.com');
return $result;
I have tried multiple other solutions, but it's still not working. What am I missing?
if it v6
$headers = ['Referer' => 'test.referer.com'];
$guzzle = new \GuzzleHttp\Client([
'headers' => $headers
]);
$result = $guzzle->get('http://google.com');
return $result;
You don't need strange param default
And need Referer
. Not referer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With