php – 如何从谷歌日历中获取活动详情
作者:互联网
当在日历中创建新事件时,我成功地从谷歌日历获取推送通知到我的系统.
推送通知在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
标签:php,google-api,calendar,google-calendar-api 来源: https://codeday.me/bug/20191008/1870407.html