Google カレンダー API を使用して非常に単純なイベントをカレンダーに追加しようとしているのですが、誰かが私の (おそらく明白な) 問題を指摘してくれれば幸いです。ここで見つけたコードを使用しています。簡単な例を見つけることができる「google-api-php-client/examples.calendar」ディレクトリにコードを配置しました。
<?php
require_once '../../src/Google_Client.php';
require_once '../../src/contrib/Google_CalendarService.php';
session_start();
$client = new Google_Client();
$client->setApplicationName("Google Calendar PHP Starter Application");
$client->setClientId('');
$client->setClientSecret('');
$client->setRedirectUri('worked.html'); //I made a file called "worked.html" in the same directory that just says "it worked!"
$client->setDeveloperKey('SecretLongDeveloperKey');
$cal = new Google_CalendarService($client);
if (isset($_GET['logout'])) {
unset($_SESSION['token']);
}
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']);
}
$authUrl = $client->createAuthUrl();
if (!$client->getAccessToken()){
$event = new Google_Event();
$event->setSummary('Halloween');
$event->setLocation('The Neighbourhood');
$start = new Google_EventDateTime();
$start->setDateTime('2012-10-31T10:00:00.000-05:00');
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime('2012-10-31T10:25:00.000-05:00');
$event->setEnd($end);
$createdEvent = $cal->events->insert('secretLongCalendarId@group.calendar.google.com', $event);
}
echo $createdEvent->getId();
?>
このスクリプトにアクセスすると、404 エラーが発生します。犯人を見つけるために、コードを調べて行をコメントアウトしようとしました-実際にイベントを挿入するのは最後から2番目の行のようです。
何かアドバイス?最も単純な例でさえ機能させることができないように見えるので、いくつかの指針を本当に感謝します。