Search code examples
phpzend-frameworkobjectprotected

How to print protected object in php


I am doing the login using twitter oauth functionality. I am getting the following object from $client = $token->getHttpClient($config) method:

Zend_Oauth_Client Object
(
    [_config:protected] => Zend_Oauth_Config Object
        (
            [_signatureMethod:protected] => HMAC-SHA1
            [_requestScheme:protected] => header
            [_requestMethod:protected] => POST
            [_version:protected] => 1.0
            [_callbackUrl:protected] => http://roomstayssvn.com/register/twittercallback
            [_siteUrl:protected] => http://twitter.com/oauth
            [_requestTokenUrl:protected] => 
            [_accessTokenUrl:protected] => 
            [_authorizeUrl:protected] => 
            [_consumerKey:protected] => b04fuaxLR2d035FN8tTkQ
            [_consumerSecret:protected] => NGPPovdXDnSpivNoMNIgA609ZJIB8GVKGgs6yEF8A
            [_rsaPrivateKey:protected] => 
            [_rsaPublicKey:protected] => 
            [_token:protected] => Zend_Oauth_Token_Access Object
                (
                    [_params:protected] => Array
                        (
                            [oauth_token] => 299516752-tksjJZUR7Q2gwrDRDpLOLCrYhySTGWz1SBwTKcRU
                            [oauth_token_secret] => 7S9R2FLuB0GT4vvy0GerThUnpkbSTeSalURib48Sx20
                            [user_id] => 299516752
                            [screen_name] => jogkunal5
                        )
                 )
             .....
             ..... and so on

I want to print user_id and screen_name. How can I print it?


Solution

  • Following should work

    $user_id = $client->getToken()->getParam('user_id');
    $screen_name = $client->getToken()->getParam('screen_name');
    

    Zend_Oauth_Client::__call() proxies any method of Zend_Oauth_Config. Zend_Oauth_Config::getToken() returns Zend_Oauth_Token Zend_Oauth_Token::getParam() gets the value for a parameter

    Read the docs from here.

    Its better you use a Good IDE that supports Zend framework.