I am using the php watch commant:
$service = new Google_Service_Calendar($client);
$channel = new Google_Service_Calendar_Channel($client);
$channel->setId('20fdedbf0-a845-11e3-1515e2-0800200c9a6689111');
$channel->setType('web_hook');
$channel->setAddress('https://www.exampel.com/app/notification');
$watchEvent = $service->events->watch('primary', $channel);
This command works fine and I get the response:
Google_Service_Calendar_Channel Object ( [address] => [expiration] => 1401960485000 [id] => 20fdedbf0-a845-11e3-1515e2-0800200c9a6689111 [kind] => api#channel [params] => [payload] => [resourceId] => HZjSdbhwcd5KMKEA3ATA31LoR-w [resourceUri] => https://www.googleapis.com/calendar/v3/calendars/primary/events?key=AIzaSyBl_Y7Y4eQDve-0DjwzBEP7_qOLo-67ouY&alt=json [token] => [type] => [modelData:protected] => Array ( ) [processed:protected] => Array ( ) )
However; In my set up url I don't get any message when something changes in my calendar. Am I missing something!?
To request push notifications, you need to set up a notification channel for each resource you want to watch. After your notification channels are set up, the Google Calendar API will inform your application when any watched resource changes.
Each watchable Google Calendar API resource has an associated watch method at a URI of the following form: To set up a notification channel for messages about changes to a particular resource, send a POST request to the watch method for the resource.
This document describes how to use push notifications that inform your application when a resource changes. The Google Calendar API provides push notifications that let you watch for changes to resources. You can use this feature to improve the performance of your application.
Note that the Google Calendar API will be able to send notifications to this HTTPS address only if there is a valid SSL certificate installed on your web server. Invalid certificates include: Self-signed certificates. Certificates signed by an untrusted source. Certificates that have been revoked.
I had a similar issue which was caused by authentication on my application.
Try sending a post request to https://www.exampel.com/app/notification
and see if it is received. If not, double check your routing or authentication.
Also ensure that the endpoint is a valid https URL. Self-signed certificates are not allowed.
Source: https://developers.google.com/google-apps/calendar/v3/push
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With