Google Calendar Push Notification watch command in php

落爺英雄遲暮 提交于 2019-12-05 09:37:45

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!