public function testConstructMethod() { $token = new AccessToken('key', 'secret'); $this->assertEquals('key', $token->getKey()); $this->assertEquals('secret', $token->getSecret()); return $token; }
/** * {@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; }
/** * 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; }