Search code examples
phpoauthcontactsyahoo

PHP stdClass - Yahoo OAuth


I am trying to fetch the contact details using Yahoo OAuth in my code. The OAuth is working correctly and I am getting the following stdClass from Yahoo:

stdClass Object ( 
    [profile] => stdClass Object ( 
            [guid] => AA5JFPBIASDFFESAETKHA 
            [birthYear] => 1980 
            [birthdate] => 1/31 
            [created] => 2008-10-08T13:59:36Z 
            [displayAge] => 32 
            [gender] => M 
            [image] => stdClass Object ( 
                [height] => 192 
                [imageUrl] => http://socialprofiles.zenfs.com/images/636fb037c2791a06fda15adda78b38f0_192.jpg 
                [size] => 192x192 [width] => 192 
           )
           [location] => Noida, India 
           [memberSince] => 2002-03-04T11:38:32Z 
           [nickname] => Himanshu 
           [profileUrl] => http://profile.yahoo.com/AA5JFPBIZUNNQRHEA6R73NTKHA 
           [status] => stdClass Object (
                     [lastStatusModified] => 2011-10-27T17:03:35Z 
                     [linkTo] => 
                     [message] => Using Yahoo! mail after a long time.... Full of features that Gmail cannot come anywhere close to..... ) 
                     [isConnected] => false 
                     )

This is the print_r of the variable $profile on line 164 of my script. Now when I am trying to use this variable in my program, it is giving me an error like this:

Notice: Undefined property: stdClass::$profileUrl in /var/www/vhosts/xyz.com/httpdocs/PHP/yahoo-api-php-client/examples/simpleauth/simpleauth.php on line 165

Line 165 in my php script is $prfurl = $profile->profileUrl;

Can anyone help me what am I doing wrong here? This is Yahoo's standard code and I have not done anything in it.


Solution

  • It should be $prfurl = $profile->profile->profileUrl;