我很难在谷歌日历上更新活动。我正在使用google-api-php-client。我想使用以下代码一次更新一个事件的描述。
my@gmail.com是我的主要帐户。
$currEvent = $service->events->get("my@gmail.com", $event_id);
$currEvent->setDescription("Test DESCRIPTION");
$service->events->update("my@gmail.com", $currEvent->getId(), $currEvent);
我正在使用上面的代码进行更新。
Get事件返回正确的结果但更新事件引发以下错误:
致命错误:未捕获的异常'Google_Service_Exception',并在/google-api-php-client/src/Google/Http/REST.php:76堆栈中显示错误'错误呼叫PUT https://www.googleapis.com/calendar/v3/calendars/my%40gmail.com/events/d6ao1oaiaa7s0aif229btheiv4?key=AIzaSyBQJ2hQzpYn8UIL97VKkg3tBFTq9nFAQUE :( 403)禁止'跟踪:#0 /google-api-php-client/src/Google/Http/REST.php(41):Google_Http_REST :: decodeHttpResponse(对象(Google_Http_Request))#1 / google-api-php-client / src / Google /Client.php(548):Google_Http_REST :: execute(Object(Google_Client),Object(Google_Http_Request))#2 /google-api-php-client/src/Google/Service/Resource.php(190):Google_Client-> ;第76行执行(对象(Google_Http_Request))#3 / in /google-api-php-client/src/Google/Http/REST.php
我尝试使用以下代码将事件添加到Google日历中,并且它正在运行:
$event = new Google_Service_Calendar_Event();
$event->setSummary('Appointment');
$event->setLocation('test location');
$start = new Google_Service_Calendar_EventDateTime();
$start->setDateTime('2014-12-12T10:00:00.000-07:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setDateTime('2014-12-12T10:25:00.000-07:00');
$event->setEnd($end);
$attendee1 = new Google_Service_Calendar_EventAttendee();
$attendee1->setEmail('abc@test.com');
// ...
$attendees = array($attendee1);
$event->attendees = $attendees;
$createdEvent = $service->events->insert('primary', $event);
echo $createdEvent->getId();
非常感谢任何帮助。
干杯!!!