/** * @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); }
/** * @expectedException \Rabus\Bundle\Twitter\SignInBundle\Service\TwitterApiException */ public function testGetRequestTokenThrowsException() { $this->factoryMock->expects($this->any())->method('getOAuthConnection')->will($this->returnValue($this->bootstrapClient())); $this->mockPlugin->addException(new CurlException()); $this->bootstrapGateway()->getRequestToken('http://www.example.com/twitter/callback'); }