setOauthToken() public méthode

public setOauthToken ( string $oauthToken, string $oauthTokenSecret )
$oauthToken string
$oauthTokenSecret string
Exemple #1
0
 /**
  * Prepare the Twitter client before sending a request
  * Reads the oauth token and secret from the Provider for Twitter authentication
  *
  * @param  string  $provider_id
  * @throws \Exception
  */
 protected function prepareRequest($provider_id)
 {
     $userProvider = $this->providerRepository->get($provider_id);
     if (empty($userProvider['oauth_token']) || empty($userProvider['oauth_token_secret'])) {
         throw new \Exception('Invalid access token');
     }
     $this->client->setOauthToken($userProvider['oauth_token'], $userProvider['oauth_token_secret']);
 }
 public function testSetOauthToken()
 {
     $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
     $twitter->setOauthToken(ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
     $this->assertObjectHasAttribute('consumer', $twitter);
     $this->assertObjectHasAttribute('token', $twitter);
     $twitter->get('friendships/show', array('target_screen_name' => 'twitterapi'));
     $this->assertEquals(200, $twitter->getLastHttpCode());
 }