【问题标题】:Google Calendar PHP retrieve events from multiple calendarsGoogle Calendar PHP 从多个日历中检索事件
【发布时间】:2011-07-11 19:51:41
【问题描述】:

我正在关注有关在 ZEND 框架中使用 Google 日历 API 的教程 (http://maestric.com/doc/php/google_calendar_api)。我可以通过设置日历 ID:$query->setUser('IDGoesHere'); 从我的默认日历中检索事件。问题是我不确定如何从我订阅的所有日历中获取事件。有没有办法做到这一点,或者甚至不可能?

感谢任何帮助。

这里是 PHP:

$path = 'ZendGdata/library';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');

$user = 'username';
$pass = 'password';
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;

try
{
$client = Zend_Gdata_ClientLogin::getHttpClient($user,$pass,$service);          
}
catch(Exception $e)
{
echo "Could not connect to calendar.";
die();
}

$gdataCal = new Zend_Gdata_Calendar($client);
$query = $gdataCal->newEventQuery();

$query->setUser('usernameHere');
$query->setVisibility('private');
$query->setSingleEvents(true);
$query->setProjection('full');
$query->setOrderby('starttime');
$query->setSortOrder('ascending');
$query->setMaxResults(20);

$event_list = $gdataCal->getCalendarEventFeed($query);

抓取事件并显示它们: foreach ($event_list as $event) { echo $event->title '; echo $event->where[0]; echo $event->content ; }

【问题讨论】:

  • 向我们展示您现在如何获取日历数据的代码。

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


【解决方案1】:

您需要 setUser 到辅助日历的用户 ID。

【讨论】:

  • 我知道我可以更改 setUser 以从我订阅的其他日历中获取事件。我正在尝试从两个用户那里获取事件并同时显示它们。
  • 您必须为每个日历提出单独的请求。它们是独立的资源。
猜你喜欢
  • 2012-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-22
  • 1970-01-01
  • 1970-01-01
  • 2013-04-23
  • 2020-02-07
相关资源
最近更新 更多