php - Google Calendar API PHP 通知到期值

标签 php google-calendar-api

我正在使用 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/

相关文章:

javascript - 第二行无法在 php 中更新

php - CSS类名后面有id吗?

php - 如何获取事件的创建者?

javascript - Google Calendar API 在尝试获取我的所有日​​历事件时返回 404

javascript - Google Calendar API - 获取用户的所有 session 邀请

php - 在 php 中使用 google calendar api v3 获取重复事件

javascript - 无法从闲忙查询中检索日历数据

php - 通过 PHP 进行 HTTP 身份验证注销

php - 如何使用 PHP 和 MySQL 在复选框中使用 boolean 值

php - mod_rewrite 添加 php 扩展?