我正在使用 PHP 成功注册 Google Calendar API 更改通知:
$service = new Google_Service_Calendar($client);
$channel = new Google_Service_Calendar_Channel($service);
$channel->setId(<some random ID>);
$channel->setType('web_hook');
$channel->setAddress('https://www.myserver.net/triggerCode.php');
$timetoExpire = time()+3600000;
$channel->setExpiration($timetoExpire);
$watchEvent = $service->events->watch('<some_calendar_name>', $channel);
除非这仅在 $channel->setExpiration 行被注释掉时才有效。
我得到一个错误,ttl 无效。我尝试将过期时间设置为几秒(例如 6000)、几毫秒(例如 600000)和 time() 加上几毫秒,但我总是遇到相同的错误:
Invalid ttl value for channel -1402834554'
我该如何设置?
最佳答案
终于成功了。此 PHP 代码有效:
$service = new Google_Service_Calendar($client);
$channel = new Google_Service_Calendar_Channel($service);
$channel->setId($uniqueID);
$channel->setType('web_hook');
$channel->setAddress('https://mydomain.net/notificationCallBack.php');
$timetoExpire = time()+3600000;
$optParams = array('ttl' => $timetoExpire);
$channel->setParams($optParams);
$watchEvent = $service->events->watch($calendarID, $channel);
上述到期日为 42 天,但到期日设置为 30 天。我猜这是上限。
关于php - Google Calendar API PHP 通知到期值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24519814/