我正在使用谷歌日历 API V3。我想使用 更新现有的与会者状态PHP API
。我正在使用以下代码。但似乎这段代码没有更新现有的与会者。例如,考虑 (shoag@test.com,enamul@test.com,test@test.com) 是某个事件的参与者,并且所有事件状态都处于待定状态。执行此代码后,我只看到 test@test.com 处于接受状态。这是我的代码。
<?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('MYCLIENT ID');
$client->setClientSecret('MY SECRET');
$client->setRedirectUri('MY RETURN URL');
$client->setDeveloperKey('MY DEV KEY');
$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']);
}
if ($client->getAccessToken()) {
// First retrieve the event from the API.
$event = new Google_Event($cal->events->get('primary', 'EVENT ID'));
$attendee1 = new Google_EventAttendee();
$attendee1->setEmail('test@test.com');
$attendee1->setResponseStatus('accepted');
$attendees = array($attendee1);
$event->attendees = $attendees;
$updatedEvent = $cal->events->update('primary', $event->getId(), $event);
$_SESSION['token'] = $client->getAccessToken();
} else {
$authUrl = $client->createAuthUrl();
print "<a class='login' href='$authUrl'>Connect Me!</a>";
}
如何更改现有与会者的状态?这是更新 API 链接https://developers.google.com/google-apps/calendar/v3/reference/events/update
。让我知道。