Hi, When I retrieve events from multiple calendars, I seem to be getting all the events duplicated amongst all the calendar feeds. I'm not sure if this a problem with my code, or perhaps I'm not understand the eventfeeds correctly. Here is the function I have written, please advise me what I am doing wrong.
Ralfe
/**
* This function retrieves events for all calendars
*
* @param date $start_date Starting date for the events to retrieve
* @param date $end_date Ending date for the events to retrieve
*/
function get_events($start_date="", $end_date=""){
$y = 0;
$this->debug("Retrieving events from calendars.");
foreach ($this->calendar_ids as $title => $id){
try {
# Create temporary calendar service
$cal = $this->service->newEventQuery();
$this->debug("Calendar Feed ['$title'] : $id.");
# Set the id of the calendar to query
if(isset($id)){
$cal->setUser($id);
}
else {
$cal->setUser('default');
}
# Set Query Options
$this->debug("Setting Event Query Options.");
$cal->setVisibility('private');
$cal->setProjection('full');
$cal->setOrderby('starttime');
# Set Time Frame
$this->debug("Setting Time Frame");
if (strlen($start_date) > 1){
$cal->setStartMin($start_date .
"T00:00:00.000+02:00");
$cal->setStartMax($end_date .
"T23:59:59.000+02:00");
}
else {
$cal->setFutureevents('true');
}
# Create Event Feed
$this->debug("Creating Event Feed.");
$event_feed =
$this->service->getCalendarEventFeed();
# Populate the Events Array
$this->debug("Retrieving events.");
$x = sizeof($this->events);
foreach ($event_feed as $e){
# Break up When String
if (isset($e->when[0])){
$when
= $e->when[0]->__toString();
$start_date
= substr($when, 8, 10);
$start_time
= substr($when, 19, 8);
$end_date
= substr($when, 44, 10);
$end_time
= substr($when, 55, 8);
}
else {
$start_date
= "";
$start_time
= "";
$end_date
= "";
$end_time
= "";
}
# Add to Array
$this->debug("Adding '" . $e->title .
"' to events array.");
$this->events[$x]->title
= $e->title;
$this->events[$x]->location
= $e->where[0]->__toString();
$this->events[$x]->description
= $e->content->text;
$this->events[$x]->start_date
= $start_date;
$this->events[$x]->start_time
= $start_time;
$this->events[$x]->end_date
= $end_date;
$this->events[$x]->end_time
= $end_time;
$this->events[$x]->calendar
= $title;
# Increment Counter
$x++;
}
$y++;
}
catch (Zend_Gdata_App_Exception $e){
$this->debug("Retrieving events Failed.");
$this->debug("ERROR : " . $e->__toString());
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---
