darkhorn Posted September 29, 2009 Share Posted September 29, 2009 I use this script: <?php require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Calendar'); Zend_Loader::loadClass('Zend_Http_Client'); Zend_Loader::loadClass('Zend_Gdata_Extension_When'); // Parameters for ClientAuth authentication $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; $user = "[email protected]"; $pass = "password"; // Create an authenticated HTTP client $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); // Create an instance of the Calendar service $service = new Zend_Gdata_Calendar($client); // Create a new entry using the calendar service's magic factory method $event= $service->newEventEntry(); // Populate the event with the desired information // Note that each attribute is crated as an instance of a matching class $event->title = $service->newTitle("My Event"); $event->where = array($service->newWhere("bla bla")); $event->content = $service->newContent(" This is my awesome event. RSVP required."); // Set the date using RFC 3339 format. $startDate = "2009-09-28"; $startTime = "23:00"; $endDate = "2009-09-29"; $endTime = "16:00"; $tzOffset = "+03"; $when = $service->newWhen(); $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00"; $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00"; // Create a new reminder object. It should be set to send an email // to the user 10 minutes beforehand. $reminder = $service->newReminder(); $reminder->method = "sms"; $reminder->minutes = "1"; // Apply the reminder to an existing event's when property //$when = $event->when[0]; $when->reminders = array($reminder); $event->when = array($when); // Upload the event to the calendar server // A copy of the event as it is recorded on the server is returned $newEvent = $service->insertEvent($event); ?> But I cannod edit the date using a time or date function When I change $startDate = "2009-09-28"; to $startDate = date("Y-m-d"); it gives me this error: Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 [Line 1, Column 376, element gd:when] Badly formatted datetime in attribute: startTime' in /users/xxx/public_html/test/Zend/Gdata/App.php:700 Stack trace: #0 /users/xxx/public_html/test/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('POST', 'http://www.goog...', Array, '<atom:entry xml...', 'application/ato...', 5) #1 /users/xxx/public_html/test/Zend/Gdata/App.php(686): Zend_Gdata->performHttpRequest('POST', 'http://www.goog...', Array, '<atom:entry xml...', 'application/ato...', 5) #2 /users/xxx/public_html/test/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('POST', 'http://www.goog...', Array, '<atom:entry xml...', 'application/ato...', NULL) #3 /users/xxx/public_html/test/Zend/Gdata/App.php(886): Zend_Gdata->performHttpRequest('POST', 'http://www.goog...', Array, '<atom:entry xml...', 'application/ato...') #4 /users/xxx/public_html/test/Zend/Gdata/App.php(956): Zend_Gdata_ in /users/xxx/public_html/test/Zend/Gdata/App.php on line 700 Why is that? The echo gives me same, first, thing. However when I come to the api it gives error. Edit: I forgot to change the end date, it should be greather than the first one. Link to comment https://forums.phpfreaks.com/topic/175981-solved-solved-google-calendar-api-and-time/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.