protected function _getApi()
    {
        $post = AnRequest::get('post', 'string');

        $api = null;

        try {

            if (isset($post['oauth_token']) && isset($post['oauth_handler'])) {
                $api = ComConnectHelperApi::getApi($post['oauth_handler']);
                $api->setToken($post['oauth_token'], isset($post['oauth_secret']) ? $post['oauth_secret'] : '');
            } else {
                $session = new AnConfig(AnRequest::get('session.oauth', 'raw', array()));

                if (! ($session->token && $session->api && $session->consumer)) {
                    return;
                }

                AnRequest::set('session.oauth', null);
                AnService::get('anahita:loader')->loadIdentifier('com:connect.oauth.consumer');

                $api = AnService::get('com:connect.oauth.service.'.$session->api, array(
                    'consumer' => new ComConnectOauthConsumer($session->consumer),
                    'token' => $session->token,
                ));
            }

        } catch (Exception $e) {
            error_log($e->getMessage());
            $api = null;
        }

        return $api;
    }
protected function _getApi()
    {
        $post = AnRequest::get('post', 'string');

        $api = null;

        try {

            if (isset($post['oauth_token']) && isset($post['oauth_handler'])) {
                $api = ComConnectHelperApi::getApi($post['oauth_handler']);
                $api->setToken($post['oauth_token'], isset($post['oauth_secret']) ? $post['oauth_secret'] : '');
            } else {
                $session = new AnConfig(AnRequest::get('session.oauth', 'raw', array()));

                if (! ($session->token && $session->api && $session->consumer)) {
                    return;
                }

                AnRequest::set('session.oauth', null);
                AnService::get('anahita:loader')->loadIdentifier('com:connect.oauth.consumer');

                $api = AnService::get('com:connect.oauth.service.'.$session->api, array(
                    'consumer' => new ComConnectOauthConsumer($session->consumer),
                    'token' => $session->token,
                ));
            }

        } catch (Exception $e) {
            error_log($e->getMessage());
            $api = null;
        }

        return $api;
    }
protected function _getApi ( ) { $ post = AnRequest :: get ( 'post' , 'string' ) ; $ api = null ; try { if ( isset ( $ post [ 'oauth_token' ] ) && isset ( $ post [ 'oauth_handler' ] ) ) { $ api = ComConnectHelperApi :: getApi ( $ post [ 'oauth_handler' ] ) ; $ api -> setToken ( $ post [ 'oauth_token' ] , isset ( $ post [ 'oauth_secret' ] ) ? $ post [ 'oauth_secret' ] : '' ) ; } else { $ session = new AnConfig ( AnRequest :: get ( 'session.oauth' , 'raw' , array ( ) ) ) ; if ( ! ( $ session -> token && $ session -> api && $ session -> consumer ) ) { return ; } AnRequest :: set ( 'session.oauth' , null ) ; AnService :: get ( 'anahita:loader' ) -> loadIdentifier ( 'com:connect.oauth.consumer' ) ; $ api = AnService :: get ( 'com:connect.oauth.service.' . $ session -> api , array ( 'consumer' => new ComConnectOauthConsumer ( $ session -> consumer ) , 'token' => $ session -> token , ) ) ; } } catch ( Exception $ e ) { error_log ( $ e -> getMessage ( ) ) ; $ api = null ; } return $ api ; }
Creates an api object either from the session or the values in the post.
Creates an api object either from the session or the values in the post .