Filtering Event List Google Calendar PHP -


i trying fetch events lie between user-given dates google calendar using following code segment:

form name="dates" method="post" action="<?php echo $_server['php_self']; ?>">   start: <input type="date" name="start">   end: <input type="date" name="end">   <br />   <input type="submit" name="submit" value="anzeigen"> </form>  <?php if(isset($_post['submit']))  {      echo "dates chosen: start " . date($_post['start']) . ' , end ' . date($_post['end']);     // api client , construct service object.     $client = getclient();     $service = new google_service_calendar($client);      // print next 10 events on user's calendar.     $calendarid = 'bkrni7gfaiumlahibu0mnifjvk@group.calendar.google.com';     $optparams = array(       'maxresults' => 10,       'orderby' => 'starttime',       'singleevents' => true,       'timemin' => date($_post['start']),     );     $results = $service->events->listevents($calendarid, $optparams);      if (count($results->getitems()) == 0) {       print "no upcoming events found.\n";     } else {       print "upcoming events:\n";       foreach ($results->getitems() $event) {         $start = $event->start->datetime;         if (empty($start)) {           $start = $event->start->date;         }         printf("%s (%s)\n", $event->getsummary(), $start);       }     } } else {     echo 'bitte ein start- und enddatum auswählen.'; } ?> 

the date picking works fine, chosen dates shown, yet following php error:

[29-may-2015 17:34:05 europe/berlin] php fatal error:  uncaught exception 'google_service_exception' message 'error calling https://www.googleapis.com/calendar/v3/calendars/bkrni7gfaiumlahibu0mnifjvk%40group.calendar.google.com/events?maxresults=10&orderby=starttime&singleevents=true&timemin=2015-05-31cest00%3a00: (400) bad request' in /html/calendar/api/google-api-php-client/src/google/http/rest.php:110 stack trace: #0 /html/calendar/api/google-api-php-client/src/google/http/rest.php(62): google_http_rest::decodehttpresponse(object(google_http_request), object(google_client)) #1 [internal function]: google_http_rest::doexecute(object(google_client), object(google_http_request)) #2 /html/calendar/api/google-api-php-client/src/google/task/runner.php(174): call_user_func_array(array, array) #3 /html/calendar/api/google-api-php-client/src/google/http/rest.php(46): google_task_runner->run() #4 /html/calendar/api/google-api-php-client/src/google/client.php(590): google_http_rest::execute(object(google_client), object(google_http_request)) #5 /html/calendar/ap in /html/calendar/api/google-api-php-client/src/google/http/rest.php on line 110 

why fail, since according this api timemin should datetime.

thanks comment of luc, found problem. now, using

$timemin = date($_post['start']) . "t00:00:00z"; $timemax = date($_post['end']) . "t00:00:00z"; 

in call api

// print appointments between given start , end date $calendarid = 'bkrni7gfaiumlahibu0mnifjvk@group.calendar.google.com'; $optparams = array(   'orderby' => 'starttime',   'singleevents' => true,   'timemin' => $timemin,   'timemax' => $timemax, ); $results = $service->events->listevents($calendarid, $optparams); 

i desired results.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -