How do I access object member that has io:protected in it.

Discussion in 'PHP' started by z0haib, Sep 12, 2011.

  1. #1
    I have this object which i have displayed below with print_r() function. I want to know how do i access accessToken member. I have tried this method too.. $client->{'auth:protected'}->accessToken .. But this doesnt work.


    
    apiClient Object
    (
        [auth:protected] => apiOAuth2 Object
            (
                [developerKey] => AIeweweqewLQLWBk6lVgqzZREg9kao8yMiMBk
                [accessToken] => Array
                    (
                        [access_token] => ywewewewewgaSq57TkcEjMupRR6R8
                        [token_type] => Bearer
                        [expires_in] => 3600
                        [refresh_token] => 1e/PY0xzzwikY
                        [created] => 1315841905
                    )
    
                [io] => apiCurlIO Object
                    (
                        [cache:private] => apiFileCache Object
                            (
                                [path:private] => /tmp/apiClient
                            )
    
                        [auth:private] => apiOAuth2 Object
     *RECURSION*
                    )
    
            )
    
        [io:protected] => apiCurlIO Object
            (
                [cache:private] => apiFileCache Object
                    (
                        [path:private] => /tmp/apiClient
                    )
    
                [auth:private] => apiOAuth2 Object
                    (
                        [developerKey] => AIzaSyB2qma_LQLWBk6lVgqzZREg9kao8yMiMBk
                        [accessToken] => Array
                            (
                        [access_token] => ywewewewewgaSq57TkcEjMupRR6R8
                        [token_type] => Bearer
                        [expires_in] => 3600
                        [refresh_token] => 1e/PY0xzzwikY
                        [created] => 1315841905
                            )
    
                        [io] => apiCurlIO Object
     *RECURSION*
                    )
    
            )
    
    
    
    )
    Code (markup):

     
    z0haib, Sep 12, 2011 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    You need to create a public method to return the accessToken, or modify the class and make accessToken public.

    Just looking at the code, why would you need to publicly access accessToken? It seems like it should be protected or private for security's sake.
     
    jestep, Sep 13, 2011 IP