Question

so heres my predicament.

Currently using Yahoo API with PHP in order to use a 'Login with Yahoo' Function on my site.

I have managed to retrieve my entire profile. Trouble is, I can't directly display the primary email associated with the account.

If I use print_r($profile) I get everything dumped from my profile. It looks like this (personal data removed):


stdClass Object ( [uri] => http://social.yahooapis.com/v1/user/*********/profile [guid] => ***** [birthdate] => / [created] => 2010-04-22T20:47:48Z [emails] => Array ( [0] => stdClass Object ( [handle] => **@gmail.com [id] => 1 [type] => HOME ) [1] => stdClass Object ( [handle] => ****@yahoo.com [id] => 2 [primary] => 1 [type] => HOME ) ) [familyName] => Surname [gender] => M [givenName] => Ricki [image] => stdClass Object ( [height] => 192 [imageUrl] => http://l.yimg.com/dh/ap/social/profile/profile_b192.png [size] => 192x192 [width] => 192 ) [lang] => en-US [memberSince] => 2010-04-08T11:22:56Z [nickname] => Ricki [profileUrl] => http://profile.yahoo.com/*********** [updated] => 2013-03-03T18:12:22Z [isConnected] => )

Using $profile->emails->handle yields nothing however. Any ideas on what to do? I can use $profile->emails which returns an Array, displayed simply as 'Array' but if i try to select from the array i get an error:

"Catchable fatal error: Object of class stdClass could not be converted to string"

Anyone?

Was it helpful?

Solution

$profile->emails[0]->handle will give you the first handle in the system.

You can also do foreach($profile->emails as $email) { print $email->handle; }

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top