繁体   English   中英

如何从谷歌日历中获取活动详情

[英]how to get event details from google calendar

当在日历中创建新事件时,我成功地从谷歌日历获取推送通知到我的系统。 推送通知在POST正文中没有数据,POST标题是这些:

[Host] => xxxxxx.xxxx.com
[Content-Type] => application/json; charset=UTF-8
[Accept] => */*
[X-Goog-Channel-ID] => xxxxxxx-xxxxxxxx-8824-f0c2166878be
[X-Goog-Channel-Expiration] => Thu, 04 Dec 2014 04:27:13 GMT
[X-Goog-Resource-State] => exists
[X-Goog-Message-Number] => 11897215
[X-Goog-Resource-ID] => xxxxxxxxxx-xxxx-pSbC27qOUfg
[X-Goog-Resource-URI] => https://www.googleapis.com/calendar/v3/calendars/xxxxxxx@gmail.com/events?key=AIzaSyC_0nytiZWHfabrpWiExxxxxxxxxxx&alt=json
[Content-Length] => 0
[Connection] => Keep-alive
[Accept-Encoding] => gzip,deflate
[User-Agent] => APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)

在日历中创建的新事件详细信息在哪里? 我怎么得到它们?

没有在线信息和谷歌文档中没有信息(搜索了几个小时): https//developers.google.com/google-apps/calendar/v3/push

活动详情在哪里?

更新:

我使用以下代码在我的日历上设置了一个手表:

service = new Google_Service_Calendar($client);         
$channel =  new Google_Service_Calendar_Channel($client);
$uuid = gen_uuid();
$channel->setId($uuid);
$channel->setType('web_hook');
$channel->setExpiration('1919995862000');

global $sugar_config;
$address = $sugar_config['site_url'] . "/index.php?entryPoint=updateFromCal";
$channel->setAddress($address);
$watchEvent = $service->events->watch($bean->google_cal_id_c, $channel);

这是我发送到谷歌日历api的频道详情:

[address] => https://mydomainXXXX/index.php?entryPoint=updateFromCal
[expiration] => 1919995862000
[id] => xxxxxxxxxxxxxxx--4558-ac19-b82e0ca32206
[kind] => 
[params] => 
[payload] => 
[resourceId] => 
[resourceUri] => 
[token] => 
[type] => web_hook
[modelData:protected] => Array
    (
    )

[processed:protected] => Array
    (
    )

我仍然在响应中获得相同的资源ID,我在日历中创建的每个新事件! 为什么我不能得到刚刚创建的事件的事件ID? 我做错了什么? 我在看活动或频道吗?

我得到的答案仍然是上面提到的答案,它始终具有相同的资源ID。

推送不包含任何数据。 它只告诉你该资源发生了变化。 您需要执行列表请求以查明它是什么。 优选地,该列表请求将是增量同步。 请在此处查看如何进行同步: https//developers.google.com/google-apps/calendar/v3/sync

要获取事件详细信息,您需要发出GET请求,该请求应将资源信息作为JSON响应返回。 您可以通过传递日历ID和事件ID来实现此目的(在这种情况下,eventId应该是您的资源ID,假设您的通知设置为监视事件)。

您缺少增量同步。 创作者自己根据我的口味略微修改:

应用程序需要做的第一件事是获得新的推送功能是订阅感兴趣的日历。 当日历发生变化时,Google会通知您的应用,并且该应用会执行API调用以获取更新。

例如,假设您有一个日历my_calendar@my-host.com。 您的应用程序托管在具有my-host.com域的服务器上,推送通知应该传递到HTTPS Web-hook https://my-host.com/notification

每次my_calendar@my-host.com更改时,Google日历服务器都会在https://my-host.com/notification上触发Web挂钩回调。 收到回调后,应用程序需要进行增量同步

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM