google plus connect API を使用して、ユーザーのメールの許可を求めることはできますが、アクセスできないようです。
私が使用しているコードは次のとおりです。
require_once '../../src/Google_Client.php';
require_once '../../src/contrib/Google_PlusService.php';
session_start();
$client = new Google_Client();
$client->setApplicationName("Test Application");
$client->setClientId('XXXXX');
$client->setClientSecret('XXXXX');
$client->setRedirectUri('XXXXX');
$client->setDeveloperKey('XXXXX');
$client->setScopes(array('https://www.googleapis.com/auth/plus.login','https://www.googleapis.com/auth/userinfo.email'));
$plus = new Google_PlusService($client);
if (isset($_REQUEST['logout'])) {
unset($_SESSION['access_token']);
}
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['access_token'])) {
$client->setAccessToken($_SESSION['access_token']);
}
if ($client->getAccessToken()) {
$me = $plus->people->get('me');
print_r($me);
}
ユーザーがメールアドレスを取得する許可を与えた後、メールアドレスを取得する方法はありますか?