我曾尝试用谷歌搜索这个问题,但没有成功,可能是因为搜索字符串“Z”不够具体。
背景:
使用 Google Calendar Zend gdata 库,并一直使用简单的代码来列出特定时间段的事件。在这种情况下,27-02-2012 到 03-03-2012。
我列出了许多单一事件,其中有一个重复发生的事件,名为“Rob”,每周一至周五。
我使用的是基本代码,没有任何花哨的添加。还:)
问题:
当我使用 $query->setSingleEvents(TRUE)
参数时,一切都按预期工作,并显示了正确的事件。
当我谈论“显示”事件时,我指的是使用 Zend gdata 显示日历事件的 PHP 页面。
在所有情况下,Google 日历 GUI 都显示正确的数据(即“Rob”事件未显示,因为它已被删除。
但是当我将其设置为 FALSE
时,重复事件“Rob”应该具有要分组的开始时间,但相反,显示了一些没有 starttime
,就是同一个标题。即使我删除了重复发生的事件,它仍然显示在 gdata 返回的数据中。
有趣的观察
已删除但仍显示在页面上的事件的 EventID 以“Z”结尾。
它具有通常的 eventID,后跟:_20120302T030000Z
我的问题
此事件已在 Google 日历 GUI 中删除。为什么gdata仍然显示删除的事件,以时间戳和Z结尾的eventid是什么意思。
解决尝试:
1. 尝试将其从循环事件更改为普通事件(删除“系列中所有事件”的循环
运气不好,仍然列出了额外的。
2. 完全删除了系列中所有事件的重复事件。
这再次显示了 SingleEvents(TRUE)
中的正确结果,但在 FALSE
中,旧的“Rob”事件仍然显示,但已从日历中完全删除。
代码:
function outputCalendarByDateRange($client, $startDate='2012-02-27',
$endDate='2012-03-03')
{
$gdataCal = new Zend_Gdata_Calendar($client);
$query = $gdataCal->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
$query->setProjection('full');
$query->setOrderby('starttime');
$query->setStartMin($startDate);
$query->setStartMax($endDate);
$query->setSingleEvents(FALSE);
$eventFeed = $gdataCal->getCalendarEventFeed($query);
foreach ($eventFeed as $event) {
echo "Title: " . $event->title->text . "<br />";
echo "Event ID: " . $event->id->text . "<br />";
foreach ($event->when as $when) {
echo "Start: " . $when->startTime . "<br />";
}
echo "<br />";
}
}
最佳答案
这是我在 docs 中找到的内容:
36.5.6. Deleting Events Calendar events can be deleted either by calling the calendar service's delete() method and providing the edit URL of an event or by calling an existing event's own delete() method.
In either case, the deleted event will still show up on a user's private event feed if an updateMin query parameter is provided. Deleted events can be distinguished from regular events because they will have their eventStatus property set to "http://schemas.google.com/g/2005#event.canceled".
看起来您必须在解析提要时测试事件状态。
顺便说一句,时间戳分解为
year:2012 day:03 month:02 time:T hours:minutes:seconds 03:00:00 zulu:Z
Zulu 与 GMT(格林威治标准时间)或 UTC(世界时码)相同
关于php - Google Calendar Gdata 旧的重复事件已删除事件仍然显示,事件 ID 以 Z 结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9411893/