public function callback($fallback_url = null)
    {
        if ($this->request->has('denied')) {
            return $this->redirect->to($fallback_url ?: $this->getFallbackUrl());
        } elseif ($this->request->has('oauth_verifier') && $this->session->has('oauth_request_verify')) {
            $this->twitter->setToken(
                $this->session->get('oauth_request_token'),
                $this->session->get('oauth_request_token_secret')
            );

            $this->session->forget('oauth_request_verify');

            $oauthVerifier = $this->request->get('oauth_verifier');

            $this->response = $this->twitter->api('POST', 'oauth/access_token', array('oauth_verifier' => $oauthVerifier));

            if ($this->responseOk()) {
                $this->session->forget('oauth_request_token');
                $this->session->forget('oauth_request_token_secret');
                $this->session->forget('oauth_request_verify');

                $data = array('oauth_token', 'oauth_token_secret', 'user_id', 'screen_name');
                foreach ($data as $key) {
                    $this->session->put("twitter.{$key}", $this->response->{$key});
                }

                return $this->response;
            }
            $this->triggerError("Invalid or expired token.");
        } else {
            $this->triggerError("To perform callback, you must authorize the user first.");
        }
    }
public function callback($fallback_url = null)
    {
        if ($this->request->has('denied')) {
            return $this->redirect->to($fallback_url ?: $this->getFallbackUrl());
        } elseif ($this->request->has('oauth_verifier') && $this->session->has('oauth_request_verify')) {
            $this->twitter->setToken(
                $this->session->get('oauth_request_token'),
                $this->session->get('oauth_request_token_secret')
            );

            $this->session->forget('oauth_request_verify');

            $oauthVerifier = $this->request->get('oauth_verifier');

            $this->response = $this->twitter->api('POST', 'oauth/access_token', array('oauth_verifier' => $oauthVerifier));

            if ($this->responseOk()) {
                $this->session->forget('oauth_request_token');
                $this->session->forget('oauth_request_token_secret');
                $this->session->forget('oauth_request_verify');

                $data = array('oauth_token', 'oauth_token_secret', 'user_id', 'screen_name');
                foreach ($data as $key) {
                    $this->session->put("twitter.{$key}", $this->response->{$key});
                }

                return $this->response;
            }
            $this->triggerError("Invalid or expired token.");
        } else {
            $this->triggerError("To perform callback, you must authorize the user first.");
        }
    }
public function callback ( $ fallback_url = null ) { if ( $ this -> request -> has ( 'denied' ) ) { return $ this -> redirect -> to ( $ fallback_url ? : $ this -> getFallbackUrl ( ) ) ; } elseif ( $ this -> request -> has ( 'oauth_verifier' ) && $ this -> session -> has ( 'oauth_request_verify' ) ) { $ this -> twitter -> setToken ( $ this -> session -> get ( 'oauth_request_token' ) , $ this -> session -> get ( 'oauth_request_token_secret' ) ) ; $ this -> session -> forget ( 'oauth_request_verify' ) ; $ oauthVerifier = $ this -> request -> get ( 'oauth_verifier' ) ; $ this -> response = $ this -> twitter -> api ( 'POST' , 'oauth/access_token' , array ( 'oauth_verifier' => $ oauthVerifier ) ) ; if ( $ this -> responseOk ( ) ) { $ this -> session -> forget ( 'oauth_request_token' ) ; $ this -> session -> forget ( 'oauth_request_token_secret' ) ; $ this -> session -> forget ( 'oauth_request_verify' ) ; $ data = array ( 'oauth_token' , 'oauth_token_secret' , 'user_id' , 'screen_name' ) ; foreach ( $ data as $ key ) { $ this -> session -> put ( "twitter.{$key}" , $ this -> response -> { $ key } ) ; } return $ this -> response ; } $ this -> triggerError ( "Invalid or expired token." ) ; } else { $ this -> triggerError ( "To perform callback, you must authorize the user first." ) ; } }
Perform callback.

@param null $fallback_url
@throws Exceptions\TwitterApiException
Perform callback .