/**
  * @param string $callbackUrl
  * @return array
  * @throws TwitterApiException
  */
 public function getRequestToken($callbackUrl = null)
 {
     $client = $this->connectionFactory->getOAuthConnection();
     $request = $client->post('oauth/request_token');
     if ($callbackUrl) {
         $request->addHeader('oauth_callback', $callbackUrl);
     }
     try {
         $response = $request->send();
     } catch (RequestException $e) {
         throw new TwitterApiException('Fetching OAuth request token failed.', 0, $e);
     }
     $token = $this->extractTokenFromResponse($response);
     if (!$token) {
         throw new TwitterApiException('Fetching OAuth request token failed.');
     }
     return $token;
 }
 public function testGetOauthConnectionWithToken()
 {
     $factory = new ConnectionFactory('foo', 'bar');
     $client = $factory->getOAuthConnection('foobar', 'barfoo');
     $this->assertInstanceOf('Guzzle\\Http\\Client', $client);
 }