我正在跟随一个关于使用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 ;
}
需要将备用日历的用户id输入setUser