Lur*_*k21 2 php google-calendar-api google-api oauth-2.0 google-oauth
我使用以下内容,基于Google的日历示例应用程序,该应用程序运行正常.
$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);
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了:
Error: invalid_request
Missing required parameter: scope
Run Code Online (Sandbox Code Playgroud)
设置developerKey后丢失了这一行
$cal = new \Google_CalendarService($client);
Run Code Online (Sandbox Code Playgroud)
我想从客户端获取日历服务的行为设置范围.很合理.