To set a custom referrer header in a Guzzle request in PHP, you can use the Referer
header option provided by Guzzle's headers
option.
Here's an example of how you can set a custom referrer header in a Guzzle request:
use GuzzleHttp\Client;
// Create a new Guzzle Client instance
$client = new Client();
// Set the request options
$options = [
'headers' => [
'Referer' => 'http://example.com', // Set your custom referrer URL here
],
];
// Send a GET request with the custom referrer header
$response = $client->get('http://api.example.com', $options);
// Handle the response
echo $response->getBody();
In this example, the custom referrer URL is set as http://example.com
. You can set your own custom referrer URL according to your needs.