如何将事件插入谷歌日历?
我正在使用本指南: https ://developers.google.com/google-apps/calendar/v3/reference/events/insert
在示例部分,有这个 php 代码:
$event = new Event();
$event->setSummary('Appointment');
$event->setLocation('Somewhere');
$start = new EventDateTime();
$start->setDateTime('2011-06-03T10:00:00.000-07:00');
$event->setStart($start);
$end = new EventDateTime();
$end->setDateTime('2011-06-03T10:25:00.000-07:00');
$event->setEnd($end);
$attendee1 = new EventAttendee();
$attendee1->setEmail('attendeeEmail');
// ...
$attendees = array($attendee1,
// ...
);
$event->attendees = $attendees;
$createdEvent = $service->events->insert('primary', $event);
echo $createdEvent->getId();
但这给了我一个致命的错误,因为 $service 是未定义的。谁能告诉我如何初始化 $service 并使这些东西工作?