B
B
Bogdan Pasechnik2015-11-03 12:01:29
PHP
Bogdan Pasechnik, 2015-11-03 12:01:29

Why can't I add an alert to the google callendar event via api?

Can't add user event notification via API. I have already tried everything, the standard example from the documentation does not work either https://developers.google.com/google-apps/calendar... . Please tell me where I'm wrong.
The title and other fields are updated. If you request an event from the calendar via the API, then there are reminders in the response, but they do not appear in the calendar itself.

$eventId = '<EVENT ID>';
$calendarId = '<CALENDAR ID>';
$secretPath = '*.json';

$client = new \Google_Client();

$credentials = $client->loadServiceAccountJson($secretPath, \Google_Service_Calendar::CALENDAR);
$client->setAssertionCredentials($credentials);

$calendar = new \Google_Service_Calendar($client);

$event = $calendar->events->get($calendarId, $eventId);

$event->setSummary('updated event '.rand(1,100)); // название обновляет без проблем

$reminder = new \Google_Service_Calendar_EventReminder();
$reminder->setMethod('email');
$reminder->setMinutes(10);

$reminders = new \Google_Service_Calendar_EventReminders();
$reminders->setUseDefault(false);
$reminders->setOverrides([$reminder]);
$event->setReminders($reminders); // оповещения не добавляет

$calendar->events->update($calendarId, $eventId, $event);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Zinchenko, 2015-11-03
@lisiy50

The question is different: "how to add an alert for another user?".
Most likely, the notification is not added for the owner of the calendar, notifications for each user are different. Therefore, before adding an alert, you need to specify who to add it to. How to do it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question