Google Calendar PHP 从多个日历中检索事件

发布于 2024-11-19 09:48:03 字数 1346 浏览 0 评论 0原文

我正在遵循有关在 ZEND Framework 中使用 Google Calendar 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 为 $event) { echo $事件->标题'; 回声 $event->where[0]; echo $事件->内容; }

I was following a tutorial on using the Google Calendar API with the ZEND Framework(http://maestric.com/doc/php/google_calendar_api). I am able to retrieve events from my default calendar by setting the calendar ID: $query->setUser('IDGoesHere');. The problem is I'm not sure how to grab events from all of the calendars I am subscribed to. Is there a way to achieve this or is it not even possible?

Any help is appreciated.

Here is the 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);

Grab the events and display them:
foreach ($event_list as $event)
{
echo $event->title ';
echo $event->where[0];
echo $event->content ;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执笔绘流年 2024-11-26 09:48:03

您需要将 setUser 设置为辅助日历的用户 ID。

You need to setUser to the user id of the secondary calendar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文