获取特定Google日历的Zend_GData Feed

问题描述:

我有一个关于如何获取特定日历的事件Feed的详细问题,但在发布之前计算(我认为)解决方案。但是,即使解决方案我仍然想知道我错过了这个过程。为了得到一个日历的事件饲料(或搜索饲料)我执行以下操作:获取特定Google日历的Zend_GData Feed

  • 进行身份验证(显然)
  • 获取日历列表:getCalendarListFeed();
  • 从 '日历' 的一个获取id属性对象
  • 变化:... /日历/供稿/默认/ XXX%40YYY
  • 要:... /日历/供稿/ XXX%40YYY /私人/全部
  • 通过getCalendarEventFeed()来查询该日历。

为什么我必须操纵ID?似乎Zend_Gdata的文档分布在Google和Zend的网站上。我没有找到来自getCalendarListFeed()的可用属性的一个很好的参考,所以也许我应该获取除ID之外的其他东西?

它似乎有是更直接的方式 - 我在这里错过了什么?

您不必操纵ID。

如果你看protocol guide,有一个<link rel="alternate" .../>元素,它包含你想要的URL。

在PHP客户端,您可以通过调用检索此链接:

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

而且,你要找的文件是在这里: http://framework.zend.com/apidoc/1.9/Zend_Gdata/Calendar/Zend_Gdata_Calendar_ListEntry.html

我一直在寻找一个答案同样的问题,并最终提出以下几点:

$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'); 

首先扔我的部分是,“用户”porti通话实际上是日历ID。然后,你可以这样做:

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

(以上应该被封闭在一个try/catch,但我懒得做,在这里。)

+0

的calendarid是的电子邮件地址日历在私人设置。 setVisibility - >('private'); #私人日历(不公开) – 2013-09-15 11:05:38