Skip to content

Instantly share code, notes, and snippets.

@tomykaira
Created January 7, 2015 10:57
Show Gist options
  • Save tomykaira/556e4e69e5fa8ec4e039 to your computer and use it in GitHub Desktop.
Save tomykaira/556e4e69e5fa8ec4e039 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