I\'m trying to get a list of events on the current week from one public Google Calendar using the Google Api.
All my configurations are good, i can do any tests, lis
I'm posting here the solution i find for my question: I calculated the desired range of dates with strtotime, in my case, all days between previous sunday and next monday. Then i pass these parametres to my request:
function getEvents($service, $calendarId){
//De un Domingo al otro
$date_inicio = date('c',strtotime( "previous sunday" ));
$date_fin = date('c',strtotime( "next monday" ));
$optParams = array(
'orderBy' => 'startTime',
'singleEvents' => TRUE,
'timeMin' => $date_inicio,
'timeMax' => $date_fin
);
$results = $service->events->listEvents($calendarId, $optParams);
if (count($results->getItems()) == 0) {
print "Ningún evento encontrado.\n";
} else {
foreach ($results->getItems() as $event) {
$start = $event->start->dateTime;
if (empty($start)) {
$start = $event->start->date;
}
printf("%s (%s)\n", $event->getSummary(), $start);
echo $start.'
'.$event->getSummary().'
'.$event->getDescription().'
';
printf("%s (%s)\n
", $event->getDescription(), $start);
}
}
}