我正在尝试使用PHP在Google日历中添加事件。以下是我的代码:
$event = new Google_Event();
$event->setSummary('Halloween');
$event->setLocation('The Neighbourhood');
$start = new Google_EventDateTime();
$start->setDateTime('2018-1-19T10:00:00.000-05:00');
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime('2018-1-19TT10:25:00.000-05:00');
$event->setEnd($end);
$createdEvent = $cal->events->insert('primary', $event);
我正在访问日历,但事件未被添加。请帮我。我正在使用this library。
答案 0 :(得分:0)
您可能需要按照官方文档中的示例进行操作:Events: insert。
// Refer to the PHP quickstart on how to setup the environment: // https://developers.google.com/google-apps/calendar/quickstart/php // Change the scope to Google_Service_Calendar::CALENDAR and delete any stored // credentials.
$event = new Google_Service_Calendar_Event(array( 'summary' => 'Google I/O 2015', 'location' => '800 Howard St., San Francisco, CA 94103', 'description' => 'A chance to hear more about Google\'s developer products.', 'start' => array(
'dateTime' => '2015-05-28T09:00:00-07:00',
'timeZone' => 'America/Los_Angeles', ), 'end' => array(
'dateTime' => '2015-05-28T17:00:00-07:00',
'timeZone' => 'America/Los_Angeles', ), 'recurrence' => array(
'RRULE:FREQ=DAILY;COUNT=2' ), 'attendees' => array(
array('email' => 'lpage@example.com'),
array('email' => 'sbrin@example.com'), ), 'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
array('method' => 'email', 'minutes' => 24 * 60),
array('method' => 'popup', 'minutes' => 10),
), ), ));
$calendarId = 'primary'; $event = $service->events->insert($calendarId, $event); printf('Event created: %s\n', $event->htmlLink);