在 PHP 中使用 google calendar api 添加重复事件的例外

发布于 2024-08-05 16:56:15 字数 662 浏览 6 评论 0原文

使用 Zend Gdata Calendar 类,如何向重复事件添加例外?

$orig = $evtFeed[0]; //the original recurrence

$ex = $gc->newEventEntry(); //gc is a Zend_Gdata_Calendar object
$ex->originalEvent = $gc->newOriginalEvent($orig->getId(), $orig->getLink('self')->href, $gc->newWhen('2009-09-23T15:00:00.000Z'));
$ex->eventStatus = $gc->newEventStatus("http://schemas.google.com/g/2005#event.canceled");

$gc->insertEvent($ex);

我已经尝试了上述代码的大约 20 种变体,但每次都会收到以下错误:

致命错误:未捕获异常“Zend_Gdata_App_HttpException”,消息“预期响应代码 200,得到 403 g:originalEvent [2009-09-23 15:00:00] 与重复事件的实例不对应。”

Using the Zend Gdata Calendar classes, how can I add an exception to a recurring event?

$orig = $evtFeed[0]; //the original recurrence

$ex = $gc->newEventEntry(); //gc is a Zend_Gdata_Calendar object
$ex->originalEvent = $gc->newOriginalEvent($orig->getId(), $orig->getLink('self')->href, $gc->newWhen('2009-09-23T15:00:00.000Z'));
$ex->eventStatus = $gc->newEventStatus("http://schemas.google.com/g/2005#event.canceled");

$gc->insertEvent($ex);

I've tried about 20 variations of the above code but I get the following error every time:

Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 403 g:originalEvent [2009-09-23 15:00:00] does NOT correspond to an instance of the recurring event.'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

画▽骨i 2024-08-12 16:56:15

好吧,经过几个小时在互联网上的搜索后,我得出的结论是 zend api 可能可以做到这一点,但我永远不会弄清楚。我最终放弃了,转而编辑重复周期并将 EXDATE 规则添加到 iCalendar 数据中。由于谷歌日历界面中的一个错误,除非您刷新页面(日历上方的刷新链接不起作用),否则以这种方式创建的异常不会显示,所以我浪费了更多时间。

如果有人找到了一种无需求助于 EXDATE 即可实现此功能的方法,请发帖,我一定会定期回来查看并标记正确答案。

更新:好吧,我明白了。我会把这个部分归咎于我是个白痴,部分归咎于谷歌可怕的命名系统。对 EventEntry 调用 getId() 实际上返回事件的编辑 URL。 OriginalEvent 构造函数只需要 URL 的实际 ID 部分,因此您必须使用子字符串来提取它。正确命名 getId() 访问器真是太好了。

Well, after hours and hours of searching on the internet, I've come to the conclusion that this may be possible with the zend api, but I will never figure it out. I finally gave up and resorted to editing the recurrence and adding EXDATE rules to the iCalendar data. Thanks to a bug in the google calendar interface, exceptions created this way don't show up unless you refresh the page (the refresh link above the calendar doesn't work) so I wasted even more time.

If anyone finds a way to get this working without resorting to EXDATE please post and I'll be sure to check back periodically and mark the correct answer.

UPDATE: Ok I figured it out. I'm going to blame this one partially on me being an idiot and partially on Google's horrible naming system. Calling getId() on an EventEntry actually returns the event's EDIT URL. The OriginalEvent constructor expects only the actual ID portion of the URL so you must use substring to extract it. How nice of them to name the getId() accessor correctly.

泅人 2024-08-12 16:56:15

您不需要解析getId,只需使用calendarEventEntry.getIcalUID()即可。

You don't need to parse getId, just use calendarEventEntry.getIcalUID().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文