这就是我的困境。
目前使用雅虎API与PHP,以便使用‘登录与雅虎’的功能,在我的网站。
我已经找到了我的全部资料。问题是,我不能直接显示与帐户相关的主电子邮件。
如果我使用print_r($profile),我会从我的个人资料中得到所有的东西。看起来是这样的(删除了个人数据):
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] => )
然而,使用$profile->emails->handle不会产生任何结果。对该怎么办有什么想法吗?我可以使用$profile->emails,它返回一个数组,它简单地显示为“Array”,但是如果我尝试从数组中选择,则会得到一个错误:
“可捕获的致命错误:无法将类stdClass的对象转换为字符串”
有没有人?
发布于 2013-03-21 21:54:32
$profile->emails[0]->handle将为您提供系统中的第一个句柄。
你也可以做foreach($profile->emails as $email) { print $email->handle; }
https://stackoverflow.com/questions/15558897
复制相似问题