Skip to content

Instantly share code, notes, and snippets.

@MikSDigital
Forked from tomykaira/guzzle.php
Created August 25, 2018 09:46
Show Gist options
  • Save MikSDigital/11e929331ab171c8e1718c5f515e399b to your computer and use it in GitHub Desktop.
Save MikSDigital/11e929331ab171c8e1718c5f515e399b to your computer and use it in GitHub Desktop.
Set user-agent in guzzle. client->setDefaultOption('headers/User-Agent', 'foo'); does not work for user-agent.
<?php
require 'vendor/autoload.php';
use Guzzle\Service\Client;
// Create a client with a base URL
$client = new Client('http://requestb.in/1ivmkhd1');
$client->setUserAgent('myuseragent');
// Send a request to https://github.com/notifications
$response = $client->get('')->send();
print($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment