更新时间:2023-12-03 10:29:34
这将返回一个包含您可能要查找的信息的GOOGLE_SERVICE_OAUT2_Userinfoplus对象:
$oauth2 = new Google_Service_Oauth2($client);
$userInfo = $oauth2->userinfo->get();
print_r($userInfo);
其中$client
是Google_Client
的实例
输出:
Google_Service_Oauth2_Userinfoplus Object
(
[internal_gapi_mappings:protected] => Array
(
[familyName] => family_name
[givenName] => given_name
[verifiedEmail] => verified_email
)
[email] =>
[familyName] =>
[gender] =>
[givenName] =>
[hd] =>
[id] => 123456
[link] => https://plus.google.com/123456
[locale] => en-GB
[name] => someguy
[picture] => https://lh3.googleusercontent.com/-q1Smh9d8d0g/AAAAAAAAAAM/AAAAAAAAAAA/3YaY0XeTIPc/photo.jpg
[verifiedEmail] =>
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)
还要注意,您还需要请求https://www.googleapis.com/auth/userinfo.profile
作用域。