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!?

4

Best Answer


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.

A PHP calendar with notifications is a great tool to stay organized and never miss important events or appointments. By utilizing PHP, you can create a dynamic calendar that allows users to add and manage events. Additionally, notifications can be implemented to remind users of upcoming events or important deadlines.

To start, you will need to set up a database to store the events and their details. This can be done using MySQL or any other database management system of your choice. Each event should have a date, time, title, and description.

Next, you can create the user interface for the calendar using HTML and CSS. This will involve displaying the calendar grid with the days of the month and allowing users to navigate between different months. You can also include buttons or links to add new events.

Once the user interface is set up, you can use PHP to retrieve the events from the database and display them on the calendar. You can use SQL queries to fetch the events based on the selected month and year. Additionally, you can implement logic to highlight the current day or display different colors for different types of events.

To add notifications, you can use PHP's built-in mail function or a third-party library to send email reminders to users. You can schedule the notifications based on the event date and time, sending reminders a certain amount of time before the event. This will ensure that users are notified in advance and can prepare accordingly.

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

I have faced this issue today, so want to add some more details here.

Google only send the headers to your URL. so if you are waiting for getting some data (just like me) you won't get any (except some cases).

Check this Google Calendar API docs for Receiving Notifications

Understanding the notification message format

All notification messages include a set of HTTP headers that have X-Goog- prefixes. Some types of notifications can also include a message body.

Here are the headers I received in my webhook callback URL.

[Host] => mydomain.com[X-Goog-Channel-ID] => 10ddfddt0-a995-10f4-1254e2-0000000a0a0609001[X-Goog-Channel-Expiration] => Thu, 11 Jan 2018 10:04:04 GMT[X-Goog-Resource-State] => exists[X-Goog-Message-Number] => 2526579[X-Goog-Resource-ID] => 9OG_a-ECJycPkpNR1ZrWSon5_i1[X-Goog-Resource-URI] => https://www.googleapis.com/calendar/v3/calendars/primary/events?maxResults=250&alt=json[Content-Length] => 0[Connection] => keep-alive[User-Agent] => APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)[Accept-Encoding] => gzip,deflate,br

I also found some additional code sample here which you can use if you want to make the request to Google API without client library.

Hope this help someone.