2011-07-11 129 views
0

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

任何帮助表示赞赏。

这里是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 ; }

+0

向我们展示您的代码,了解您现在如何获取日历数据。 – Brad

+0

更新了我的原始帖子。 – downtomike

回答

0

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

+0

我知道我可以更改'setUser'来从我订阅的其他日历中抓取事件。我试图抓住两个用户的事件并同时显示它们。 – downtomike

+1

您必须为每个日历分别提出请求。他们是独立的资源。 –