2
我使用以下,基於谷歌的日曆示例應用程序工作正常。PHP谷歌API - 遺失範圍
$client = new \Google_Client();
$client->setApplicationName("Google Calendar PHP Starter Application");
$client->setClientId('myclientid.apps.googleusercontent.com');
$client->setClientSecret('mysecret');
$client->setRedirectUri('http://localhost/admin/index.php?m=1&e=calendar');
$client->setDeveloperKey('mykey');
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
if (!$client->getAccessToken()) {
$authUrl = $client->createAuthUrl();
header('Location: ' . $authUrl);
}
但我發現了:
Error: invalid_request
Missing required parameter: scope
謝謝!試圖解決這個問題,使用谷歌的令人驚訝的好文檔 工作得不太好。 –
Cyprus106