I have successfully integrated with Google Calendar using PHP with a Service Account.
What I can do:
- Update the calendar event.
- Add attendees to the calendar event.
What I can not do:
- Send invite emails when new attendees are added.
Here is the entire code that I use to accomplish everything so far:
putenv('GOOGLE_APPLICATION_CREDENTIALS=credentials.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setScopes('https://www.googleapis.com/auth/calendar');
$client->setSubject('example@gmail.com');
$service = new Google_Service_Calendar($client);
$calendarID = 'primary';
$eventID = 'XXXXXXXXX';
$event = new Google_Service_Calendar_Event(array(
'sendNotifications' => true,
'attendees' => array(
array('email' => 'email1@gmail.com)
)
));
$event = $service->events->patch($calendarID, $eventID, $event);
Late to the party but since there are no answers...
I've just been having this exact same problem. Few things:
sendNotifications
is deprecated, you should be using sendUpdates instead.$event = $service->events->patch( $calendarID, $eventID, $event, ['sendUpdates' => 'all'] );