how to create an event on google calendar using php

后端 未结 3 1716
南笙
南笙 2021-02-11 05:39

am trying to sync. events from my website to google *calendar* after

user give me a permission to write on calendar .

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-11 06:05

    The reference seems out of date - the class names are incomplete (creating google calendar event)

    Here's the updated snippet:

    require_once 'google-api-php-client/src/Google_Client.php';
    require_once 'google-api-php-client/src/contrib/Google_CalendarService.php';
    
    $event = new Google_Event();
    $event->setSummary('Appointment');
    $event->setLocation('Somewhere');
    $start = new Google_EventDateTime();
    $start->setDateTime('2011-06-03T10:00:00.000-07:00');
    $event->setStart($start);
    $end = new Google_EventDateTime();
    $end->setDateTime('2011-06-03T10:25:00.000-07:00');
    $event->setEnd($end);
    $attendee1 = new Google_EventAttendee();
    $attendee1->setEmail('attendeeEmail');
    // ...
    $attendees = array($attendee1,
                       // ...
                      );
    $event->attendees = $attendees;
    
    $createdEvent = $cal->events->insert('primary', $event);
    echo $createdEvent->id;
    

提交回复
热议问题