我正在使用谷歌日历API V3。我想使用PHP API
更新现有与会者状态。我正在使用以下代码。但似乎此代码并未更新现有与会者。例如,考虑(shohag @ 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
。让我知道。
答案 0 :(得分:0)
就像在Google日历用户界面中一样,与会者状态只能由与会者自行修改。如果所有这些用户都在同一个Google Apps域中,您可以通过service account作为与会者进行授权并更改其状态。