5

关于如何获取特定日历的事件提要,我有一个很长的详细问题,但在我发布之前(我认为)想出了一个解决方案。然而,即使有了解决方案,我仍然想知道我在这个过程中缺少什么。要获取单个日历的事件提要(或搜索该提要),我执行以下操作:

  • 验证(显然)
  • 获取日历列表:getCalendarListFeed();
  • 从“日历”对象之一获取 id 属性
  • 更改:.../calendar/feeds/default/XXX%40YYY
  • 收件人:.../calendar/feeds/XXX%40YYY/private/full
  • 将其传递给 getCalendarEventFeed() 以查询该日历。

为什么我必须操纵 ID?Zend_Gdata 的文档似乎分布在 Google 和 Zend 的网站上。我没有找到关于 getCalendarListFeed() 可用属性的良好参考,所以也许我应该获取 ID 以外的其他内容?

似乎必须更直接的方法 - 我在这里错过了什么?

4

2 回答 2

3

You don't have to manipulate the ID.

If you look at the protocol guide, there's a <link rel="alternate" .../> element which contains the URL you want.

In the PHP client, you can retrieve this link by calling:

// $entry is an instance of Zend_Gdata_Calendar_ListEntry
$link = $entry->getAlternateLink()->getHref();

Also, the documentation you're looking for is here: http://framework.zend.com/apidoc/1.9/Zend_Gdata/Calendar/Zend_Gdata_Calendar_ListEntry.html

于 2009-12-22T09:13:23.383 回答
2

我一直在寻找同一个问题的答案,最终得出以下结论:

$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$Client = Zend_Gdata_ClientLogin::getHttpClient('googleaccount','googlepass',$service);
$Service = new Zend_Gdata_Calendar($Client);

$Query = $Service->newEventQuery();
$Query->setUser('calendarid'); # As you know, you can obtain this with getCalendarListFeed()
$Query->setVisibility('public');
$Query->setProjection('full');
$Query->setOrderby('starttime');
$Query->setFutureevents('true');

起初让我失望的部分是调用的“用户”部分实际上是日历 ID。然后您可以执行以下操作:

$events = $Service->getCalendarEventFeed($Query);
foreach ($events as $Event)
{
   // work with Event object here...
}

(上面确实应该包含在 try/catch 中,但我懒得在这里这样做。)

于 2009-12-31T20:54:49.230 回答