我正在使用 Google+ 登录以检索用户的基本个人资料信息(姓名、网址、位置、个人资料图片)。但我还想检索用户朋友的用户 ID,以便我可以向他/她更好地建议用户在我的网站中已经知道的人。
$app_access_token = GetCH();
function GetCH(){
$ch = curl_init();
$pieces = explode(",", $_SESSION['access_token']); $piece = explode(":", $pieces[0]);
$token = str_replace('"',"",$piece[1]);
$url = "https://www.googleapis.com/oauth2/v1/userinfo?access_token=".$token;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETU`enter code here`RNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
if(substr($url,0,8)=='https://'){
curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
}
$sendCH = curl_exec($ch);
curl_close($ch);
return $sendCH;
};
if ($client->getAccessToken()){
$me = $plus->people->get('me');
$user_id = filter_var($me['id'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
$url = filter_var($me['url'], FILTER_VALIDATE_URL);
$img = filter_var($me['image']['url'], FILTER_VALIDATE_URL);
$name = filter_var($me['displayName'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
// The access token may have been updated lazily.
$_SESSION['access_token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
}
欲了解更多信息:https ://developers.google.com/apis-explorer/#p/plus/v1/ 但我无法弄清楚如何从他们的 API 中获取朋友列表作为数组
提前致谢