我一直在通过互联网阅读,但没有任何代码可以更新活动。事件ID从其他页面发送。这很有效。
$eventId= $_GET['id'];
$event = new Google_Event($service->events->get($calendarId, $eventId));
$event->setLocation('Home');
$event->setSummary('Summary');
//$start = new Google_EventDateTime();
//$start->setDateTime($fstart);
//$event->setStart($start);
//$end = new Google_EventDateTime();
//$end->setDateTime($ssend);
//$event->setEnd($fEnd);
$updated = new Google_Event($service->events->update($calendarId, $event->getId(), $event));
执行此操作时,我收到错误消息:
(get)缺少必需的参数:'eventId'
我最初做过
echo 'Event ID:' .$eventId;
这给了我正确的权利。
我已经有3个星期没有这段代码了。
这是没有表格的完整页面:
<?php
error_reporting(E_ALL);
//Required Files
include ($_SERVER['DOCUMENT_ROOT']."/style/style.php");
require_once($_SERVER['DOCUMENT_ROOT']."/google/src/autoload.php");
require_once($_SERVER ['DOCUMENT_ROOT']."/google/src/Google_Client.php");
require_once($_SERVER['DOCUMENT_ROOT']."/google/src/contrib/Google_CalendarService.php");
//Developpers Account details
$client_id = 'xxx.apps.googleusercontent.com';
$Email_address = 'xxx@developer.gserviceaccount.com';
$key_file_location = ($_SERVER ['DOCUMENT_ROOT']."/key/xxx.p12");
$scopes ="https://www.googleapis.com/auth/calendar";
$calid = "xxx@gmail.com";
//Set new Client
$client = new Google_Client();
$client->setUseObjects(true);
$client->setApplicationName("Update");
$client->setClientId($client_id);
$client->setAssertionCredentials(
new Google_AssertionCredentials
(
$Email_address,
array(
$scopes
),
file_get_contents($key_file_location)
)
);
$service = new Google_CalendarService($client);
//Retreive Event
$eventId= $_GET['id'];//sended thru POST by url
// First retrieve the event from the API.
$event = $service->events->get($calid,$eventId);
$event->setSummary('Hello there');
$event->setLocation('Somewhere');
$updatedEvent = $service->events->update($calid, $event->getId(),$event);
// Print the updated date.
echo $updatedEvent->getUpdated();
?>