Google Calendar PHP 从多个日历中检索事件
我正在遵循有关在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将
setUser
设置为辅助日历的用户 ID。You need to
setUser
to the user id of the secondary calendar.