public function testSetClientIDAndDeveloperKeyHeader() { $applicationId = 'MyTestCompany-MyTestApp-0.1'; $clientId = 'MyClientId'; $developerKey = 'MyDeveloperKey'; $httpClient = new \Zend\Http\Client(); $yt = new YouTube($httpClient, $applicationId, $clientId, $developerKey); $this->assertTrue($yt instanceof YouTube); $client = $yt->getHttpClient(); $this->assertEquals($client->getHeader('User-Agent'), \ZendGData\App::getUserAgentString($applicationId)); $this->assertEquals($client->getHeader('X-GData-Key'), 'key=' . $developerKey); $this->assertEquals($client->getHeader('X-GData-Client'), $clientId); }
/** * Retrieve a HTTP client object with AuthSub credentials attached * as the Authorization header * * @param string $token The token to retrieve information about * @param HttpClient $client (optional) HTTP client to use to make the request * @return HttpClient */ public static function getHttpClient($token, HttpClient $client = null) { if ($client == null) { $client = new HttpClient(); } $useragent = App::getUserAgentString(); $client->setOptions(array('strictredirects' => true, 'useragent' => $useragent)); $client->setAuthSubToken($token); return $client; }