我已经搜索了所有文档,但只得到了姓名,出生日期和个人资料网址,但没有得到我登录的用户电子邮件。那么您有什么解决方案吗? 我已经尝试过
require_once 'vendor/autoload.php';
session_start();
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setClientId('801374364215-
lop7t6qd8jis81j2nqmai9pkicd7ikej.apps.googleusercontent.com');
$client->setClientSecret('apowURdC4urZ8U6cvxeolskv');
$client->setRedirectUri('http://localhost/tosrean/node_modules/quickstart.php');
$client->setScopes(array('https://www.googleapis.com/auth/plus.login'));
$plus = new Google_Service_Plus($client);
error_reporting(E_ERROR | E_PARSE);
$code = isset($_GET['code']) ? $_GET['code'] : NULL;
if(isset($code)) {
try {
$token = $client->fetchAccessTokenWithAuthCode($code);
$client->setAccessToken($token);
}catch (Exception $e){
echo $e->getMessage();
}
}
if ($client->getAccessToken()) {
$profile = $plus->people->get('me');
echo $profile['emails'][0]['value'];
} else {
$authUrl = $client->createAuthUrl();
}