Google Calendar API PHP通知到期值 [英] Google Calendar API PHP Notification Expiration Value

查看:106
本文介绍了Google Calendar API PHP通知到期值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用PHP成功注册了Google Calendar API更改通知:

I am successfully registering for Google Calendar API Change Notifications using PHP:

$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行被注释掉的情况下,此选项才起作用.

EXCEPT this only works if the $channel->setExpiration line is commented out.

我收到一个错误消息,即ttl无效.我尝试将到期时间设置为秒数(例如6000),毫秒数(例如600000)和time()加上几毫秒,我总是得到相同的错误:

I get an error the ttl is invalid. I have tried setting the expiration to a number of seconds (e.g. 6000), a number of milliseconds (e.g. 600000), and time() plus some milliseconds and I always get the same error:

Invalid ttl value for channel -1402834554'

我应该如何设置?

推荐答案

最后使它正常工作.此PHP代码有效:

Finally got it working. This PHP code works:

 $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天.我猜这是上限.

The above expiration is 42 days hence but the expiration winds up set to 30 days hence. I am guessing that that is the upper limit.

这篇关于Google Calendar API PHP通知到期值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆