【问题标题】:Getting Zend_GData Feed for a Specific Google Calendar获取特定 Google 日历的 Zend_GData Feed
【发布时间】:2013-11-06 09:35:17
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: php zend-framework gdata-api gdata google-calendar-api


    【解决方案1】:

    您不必操纵 ID。

    如果您查看protocol guide,就会发现<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 中,但我懒得在这里这样做。)

      【讨论】:

      • calendarid 是私人设置中日历的邮箱地址。 setVisibility->('private'); # 用于私人日历(非公开)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-16
      • 1970-01-01
      相关资源
      最近更新 更多