我尝试在特定日历中插入带有 google-api-php-client 的事件。如果我设置“主要”而不是日历 ID,它正在工作,但我在主日历中看不到该事件。
我尝试指定一个日历 ID,例如 co-xxxxx.ch_lhr1ojekr990m475kv6nilueqs@group.calendar.google.com,我有以下错误:
致命错误:未捕获的异常“Google_Service_Exception”和消息“调用 POST 时出错https://www.googleapis.com/calendar/v3/calendars/xxxxx8egm4tng6rlj8usmavdu8%40google.com/events : (404) Not Found” in /var/www/ clients/client1/web347/web/google-api-php/src/Google/Http/REST.php:111 堆栈跟踪:#0 /var/www/clients/client1/web347/web/google-api-php/src /Google/Http/REST.php(63): Google_Http_REST::
这是我的代码。身份验证确实有效
$cal_id = 'primary'; // IT WORKS, BUT I DON'T SEE THE EVENT IN MAIN CALENDAR
$cal_id = 'xxxxx38egm4tng6rlj8usmavdu8@google.com'; // IT CAUSES THE ERROR
//Set the Event data
$event = new Google_Service_Calendar_Event();
$event->setSummary($title);
$event->setDescription($desc);
$ev_date = '2015-01-05T08:00:00+01:00';
$start = new Google_Service_Calendar_EventDateTime();
$start->setTimeZone('Europe/London');
$start->setDateTime('2015-01-01T19:15:00');
$event->setStart($start);
$end = new Google_Service_Calendar_EventDateTime();
$end->setTimeZone('Europe/London');
$end->setDateTime('2015-01-05T20:15:00');
$event->setEnd($end);
$createdEvent = $calendarService->events->insert( $cal_id, $event);
$event = $calendarService->events->get($cal_id, $createdEvent->getId());
//
if ($event != null) {
echo "Inserted:";
echo "EventID=".$event->getId();
echo "Summary=".$event->getSummary();
echo "Status=".$event->getStatus();
}
$createdEvent 使用“主”日历返回此代码
Google_Service_Calendar_Event Object
(
[collection_key:protected] => recurrence
[internal_gapi_mappings:protected] => Array
(
)
[anyoneCanAddSelf] =>
[attendeesType:protected] => Google_Service_Calendar_EventAttendee
[attendeesDataType:protected] => array
[attendeesOmitted] =>
[colorId] =>
[created] => 2015-01-05T11:21:03.000Z
[creatorType:protected] => Google_Service_Calendar_EventCreator
[creatorDataType:protected] =>
[description] => test
[endType:protected] => Google_Service_Calendar_EventDateTime
[endDataType:protected] =>
[endTimeUnspecified] =>
[etag] => "2840913726324000"
[extendedPropertiesType:protected] => Google_Service_Calendar_EventExtendedProperties
[extendedPropertiesDataType:protected] =>
[gadgetType:protected] => Google_Service_Calendar_EventGadget
[gadgetDataType:protected] =>
[guestsCanInviteOthers] =>
[guestsCanModify] =>
[guestsCanSeeOtherGuests] =>
[hangoutLink] =>
[htmlLink] => https://www.google.com/calendar/event?eid=M2p2ZXY1cmZpY2Y3dTk5MjQ0ZmNsYW9xNTggMTAwNjUzNTQ3ODk1My1laTI5a2M4cGQxZHE3cDUycGhtdmRlMWs3dXZkZjIzb0BkZXZlbG9wZXIuZ3NlcnZpY2VhY2NvdW50LmNvbQ
[iCalUID] => 3jvev5rficf7u99244fclaoq58@google.com
[id] => 3jvev5rficf7u99244fclaoq58
[kind] => calendar#event
[location] =>
[locked] =>
[organizerType:protected] => Google_Service_Calendar_EventOrganizer
[organizerDataType:protected] =>
[originalStartTimeType:protected] => Google_Service_Calendar_EventDateTime
[originalStartTimeDataType:protected] =>
[privateCopy] =>
[recurrence] =>
[recurringEventId] =>
[remindersType:protected] => Google_Service_Calendar_EventReminders
[remindersDataType:protected] =>
[sequence] => 0
[sourceType:protected] => Google_Service_Calendar_EventSource
[sourceDataType:protected] =>
[startType:protected] => Google_Service_Calendar_EventDateTime
[startDataType:protected] =>
[status] => confirmed
[summary] => test
[transparency] =>
[updated] => 2015-01-05T11:21:03.162Z
[visibility] =>
[modelData:protected] => Array
(
[creator] => Array
(
[email] => 1006535478953-ei29kc8pd1dq7p52phmvde1k7uvdf23o@developer.gserviceaccount.com
[self] => 1
)
[organizer] => Array
(
[email] => 1006535478953-ei29kc8pd1dq7p52phmvde1k7uvdf23o@developer.gserviceaccount.com
[self] => 1
)
[start] => Array
(
[dateTime] => 2015-01-01T19:15:00Z
[timeZone] => Europe/London
)
[end] => Array
(
[dateTime] => 2015-01-05T20:15:00Z
[timeZone] => Europe/London
)
[reminders] => Array
(
[useDefault] => 1
)
)
[processed:protected] => Array
(
)
)