Google Calendar PHP retrieve events from multiple calendars
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/li开发者_运维百科brary';
$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 ;
}
You need to setUser
to the user id of the secondary calendar.
精彩评论