簡體   English   中英

獲取特定Google日歷的Zend_GData Feed

[英]Getting Zend_GData Feed for a Specific Google Calendar

我有一個很長的詳細問題,關於如何獲取特定日歷的事件提要,但在我發布之前想到了(我認為)解決方案。 然而,即使有了解決方案, 我仍然想知道我對這個過程缺少什么。 要獲取單個日歷的事件訂閱源(或搜索該訂閱源),請執行以下操作:

  • 認證(顯然)
  • 獲取日歷列表:getCalendarListFeed();
  • 從其中一個“日歷”對象中獲取id屬性
  • 更改:... / calendar / feeds / default / XXX%40YYY
  • 要:... / calendar / feeds / XXX%40YYY / private / full
  • 將其傳遞給getCalendarEventFeed()以查詢該日歷。

為什么我要操縱ID? 似乎Zend_Gdata的文檔遍布Google和Zend的網站。 我沒有找到一個關於getCalendarListFeed()的可用屬性的好參考,所以也許我應該抓住ID以外的東西?

好像必須更直接的方式-我缺少什么嗎?

您不必操縱ID。

如果查看協議指南 ,則會有一個<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');

最初拋棄我的部分是,呼叫的“用戶”部分實際上是日歷ID。 然后你可以這樣做:

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

(以上內容應該包含在try / catch中,但是我在這里做得太懶了。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM