I can't seem to make sense of this article.
I'm trying to create 2-way syncing of events between my web app and Google Calendar. I've got my events successfully syncing to Google Calendar, but the push notifications Google sends me aren't of any use.
When I create a new event, and then I create a watch:
$channel = new Google_Service_Calendar_Channel();
$channel->setId($watchId);
$channel->setType('web_hook');
$channel->setAddress(URL::route('gapi.watchEvent'));
$channel->setResourceId($seg->gapi_event_id); // does this do anything??
$channel->setToken(json_encode(['segment_id'=>$seg->id]));
$channel->setParams([
'ttl' => 2628000, // is this respected??
]);
$watchResp = $calendarService->events->watch($googleCalendarId, $channel);
Firstly, does $channel->setResourceId
do anything? I want to listen to changes to a specific event, but always seems to give me notifications for the entire calendar.
The headers that Google sends me look like this:
"X-Goog-Channel-Id": "qJSdaxkKKkXXXXXXXXXX",
"X-Goog-Channel-Expiration": "Thu, 10 Sep 2015 01:45:57 GMT",
"X-Goog-Resource-State": "exists",
"X-Goog-Message-Number": "1811101",
"X-Goog-Resource-Id": "wBkuOkYwEhDiXXXXXXXXX",
"X-Goog-Resource-Uri": "https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?alt=json",
The X-Goog-Channel-Id
is the watch id that I chose. X-Goog-Resource-Uri
appears to just be a link to the calendar. And I don't know what X-Goog-Resource-Id
. It doesn't appear to be either my calendar ID or my event ID.
All I want to know is what data changed? How do I extract that information out of the push notification?
I don't care if I have to subscribe to every event my app creates, or just once per calendar.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…