Ejemplo n.º 1
0
 public function testConstructMethod()
 {
     $token = new AccessToken('key', 'secret');
     $this->assertEquals('key', $token->getKey());
     $this->assertEquals('secret', $token->getSecret());
     return $token;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getIdentity(AccessToken $accessToken)
 {
     $this->consumerToken = $accessToken;
     $parameters = $this->requestTokenParams;
     $parameters['user_id'] = $accessToken->getUserId();
     $response = $this->oauthRequest($this->getBaseUri() . 'users/lookup.json', Client::GET, $parameters, $this->requestTokenHeaders);
     if ($response->getStatusCode() == 200) {
         $result = $response->json();
         $hydrator = new ObjectMap(array());
         return $hydrator->hydrate(new User(), $result[0]);
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * Parse AccessToken from response's $body
  *
  * @param mixed $body
  * @return AccessToken
  * @throws InvalidAccessToken
  */
 public function parseAccessToken($body)
 {
     if (!is_string($body)) {
         throw new RuntimeException('Request $body is not a string, passed: ' . var_export($body));
     }
     parse_str($body, $token);
     if (!is_array($token) || !isset($token['oauth_token']) || !isset($token['oauth_token_secret'])) {
         throw new InvalidAccessToken();
     }
     $accessToken = new AccessToken($token['oauth_token'], $token['oauth_token_secret']);
     if (isset($token['user_id'])) {
         $accessToken->setUserId($token['user_id']);
     }
     return $accessToken;
 }