drummer392
drummer392

Reputation: 473

Google Calendar PHP API Not Sending Invite Emails

I have successfully integrated with Google Calendar using PHP with a Service Account.

What I can do:

What I can not do:

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('[email protected]');

$service = new Google_Service_Calendar($client);

$calendarID = 'primary';
$eventID = 'XXXXXXXXX';
$event = new Google_Service_Calendar_Event(array(
    'sendNotifications' => true,
    'attendees' => array(
        array('email' => '[email protected])
    )
));

$event = $service->events->patch($calendarID, $eventID, $event);

Upvotes: 2

Views: 1987

Answers (1)

Danny Battison
Danny Battison

Reputation: 533

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.
  • The optional Params don't go on the event itself - they go in the request. So you end up with:
$event = $service->events->patch(
    $calendarID, 
    $eventID, 
    $event, 
    ['sendUpdates' => 'all']
);

Upvotes: 6

Related Questions