我看了this article
我不明白,在获得访问令牌后,我可以通过哪个端点获取已登录用户的电子邮件地址?
我的步骤:
1-将用户发送到yahoo登录页面:
https://api.login.yahoo.com/oauth2/request_auth?client_id={client_id}&redirect_uri={redirect_uri}&response_type=code
2-确认yahoo将用户重定向到我的redirect_uri并使用代码参数
3-我接收到的代码并与雅虎建立POST连接并向其发送代码,雅虎给我访问令牌:
$postdata = array(
'grant_type'=>'authorization_code',
'code'=>$_GET['code'],
'redirect_uri'=>'{redirect_uri}'
);
$header = array('Authorization: Basic '.base64_encode({client_id}.':'.{client_secret}));
curl("https://api.login.yahoo.com/oauth2/get_token","POST",$postdata,$header);
5-之后,我与雅虎建立GET连接以提供登录的用户配置文件:
$header = array('Authorization: Bearer {access_token}');
curl('https://social.yahooapis.com/v1/user/me/profile?format=json',"GET",array(),$header);
没有用户电子邮件回复:
object(stdClass)#2 (1) {
["profile"]=>
object(stdClass)#3 (25) {
["guid"]=>
string(26) "3KFOKEMJXONWVU2HNL3EAKQNIQ"
["ageCategory"]=>
string(1) "A"
["birthYear"]=>
int(1990)
["created"]=>
string(20) "2011-03-05T11:12:04Z"
["displayAge"]=>
int(25)
["followMode"]=>
string(5) "ALLOW"
["gender"]=>
string(1) "M"
["image"]=>
object(stdClass)#4 (4) {
["height"]=>
int(192)
["imageUrl"]=>
string(56) "https://s.yimg.com/dh/ap/social/profile/profile_b192.png"
["size"]=>
string(7) "192x192"
["width"]=>
int(192)
}
["intl"]=>
string(2) "us"
["jurisdiction"]=>
string(2) "us"
["lang"]=>
string(5) "en-US"
["memberSince"]=>
string(20) "2011-03-05T11:11:42Z"
["migrationSource"]=>
int(1)
["nickname"]=>
string(12) "Saeid Ezzati"
["nux"]=>
string(1) "3"
["profileMode"]=>
string(6) "PUBLIC"
["profileStatus"]=>
string(6) "ACTIVE"
["profileUrl"]=>
string(51) "http://profile.yahoo.com/3KFOKEMJXONWVU2HNL3EAKQNIQ"
["searchable"]=>
bool(true)
["updated"]=>
string(20) "2015-06-22T10:23:38Z"
["isConnected"]=>
bool(false)
["profileHidden"]=>
bool(false)
["profilePermission"]=>
string(7) "PRIVATE"
["uri"]=>
string(71) "https://social.yahooapis.com/v1/user/3KFOKEMJXONWVU2HNL3EAKQNIQ/profile"
["cache"]=>
bool(true)
}
}