如何在php中打印受保护的对象

时间:2013-01-09 11:47:38

标签: php zend-framework object protected

我正在使用twitter oauth功能进行登录。我从$client = $token->getHttpClient($config)方法获取以下对象:

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

我想打印user_idscreen_name。我该如何打印?

1 个答案:

答案 0 :(得分:4)

以下应该工作

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

Zend_Oauth_Client::__call()代理Zend_Oauth_Config的任何方法。 Zend_Oauth_Config::getToken()返回Zend_Oauth_Token Zend_Oauth_Token::getParam()获取参数

的值

阅读here中的文档。

最好使用支持Zend框架的Good IDE。