首页 文章

获取特定Google日历的Zend_GData Feed

提问于
浏览
5

我有一个很长的详细问题,关于如何获取特定日历的事件提要,但在我发布之前想到了(我认为)解决方案 . 但是,即使使用解决方案 I'm left wondering what I'm missing about this process. 要获取单个日历的事件订阅源(或搜索该订阅源),我会执行以下操作:

  • 认证(显然)

  • 获取日历列表:getCalendarListFeed();

  • 从'calendar'对象之一获取id属性

  • 更改:... / calendar / feeds / default / XXX%40YYY

  • 收件人:... / calendar / feeds / XXX%40YYY / private / full

  • 将其传递给getCalendarEventFeed()以查询该日历 .

Why do I have to manipulate the ID? 似乎Zend_Gdata的文档遍布Google _1377041的所有网站 . 我没有找到一个关于getCalendarListFeed()的可用属性的好参考,所以也许我应该 grab ID以外的东西?

似乎必须有更直截了当的方式 - 我在这里缺少什么?

2 回答

  • 3

    您不必操纵ID .

    如果查看protocol guide,则会有一个包含所需URL的 <link rel="alternate" .../> 元素 .

    在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

  • 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中,但是我在这里做得太懒了 . )

相关问题