예제 #1
0
 /**
  * {@inheritdoc}
  */
 protected function createTemporaryCredentials($body)
 {
     parse_str($body, $data);
     if (!$data || !is_array($data)) {
         throw new CredentialsException('Unable to parse temporary credentials response.');
     }
     $temporaryCredentials = new TemporaryCredentials();
     $temporaryCredentials->setIdentifier($data['oauth_token']);
     $temporaryCredentials->setSecret($data['oauth_token_secret']);
     return $temporaryCredentials;
 }
예제 #2
0
파일: Server.php 프로젝트: kc22033/afhdev
 /**
  * Creates temporary credentials from the body response.
  *
  * @param  string  $body
  * @return TemporaryCredentials
  */
 protected function createTemporaryCredentials($body)
 {
     parse_str($body, $data);
     if (!$data || !is_array($data)) {
         throw new CredentialsException("Unable to parse temporary credentials response.");
     }
     if (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') {
         throw new CredentialsException("Error in retrieving temporary credentials.");
     }
     $temporaryCredentials = new TemporaryCredentials();
     $temporaryCredentials->setIdentifier($data['oauth_token']);
     $temporaryCredentials->setSecret($data['oauth_token_secret']);
     return $temporaryCredentials;
 }
예제 #3
0
 /**
  * Once we have token, we can run the authorization which than give us the option to request the access token.
  *
  * @param string $requestToken Request token returned by getRequestToken method.
  * @param string $requestTokenSecret Request token secret returned by getRequestToken method.
  * @param string $oauthToken OAuth token returned by Twitter OAuth server.
  * @param string $oauthTokenVerifier OAuth token verifier returned by Twitter OAuth server.
  *
  * @return array[oauth_token, oauth_token_secret]
  */
 public function requestAccessToken($requestToken, $requestTokenSecret, $oauthToken, $oauthTokenVerifier)
 {
     $ti = new TemporaryCredentials();
     $ti->setIdentifier($requestToken);
     $ti->setSecret($requestTokenSecret);
     $tc = $this->instance->getTokenCredentials($ti, $oauthToken, $oauthTokenVerifier);
     $token = ['oauth_token' => $tc->getIdentifier(), 'oauth_token_secret' => $tc->getSecret()];
     $this->setAccessToken($token);
     return $token;
 }