使用Requests for PHP库,如何设置自定义用户代理?

I'm doing some testing of Requests for PHP and I'd like to set a custom user-agent for a basic GET request.

Peeking at the source code, I thought perhaps this test would pass:

$url = 'http://httpbin.org/user-agent';
$user_agent = 'my-test-agent';

$options = array('useragent', $user_agent);
$response = Requests::get($url, array(), $options);
$json = json_decode($response->body, true);

$this->assertEqual($json['user-agent'], $user_agent);

However, http://httpbin.org/user-agent returns the default library value php-requests/1.6 as the user-agent.

Is it possible to do this or do I need to use the Requests_Session object as demonstrated here?

You have to define the options this way:

$options = array('useragent' => $user_agent);