I've been trying to work wit the ZEND GData API in CakePHP and have it setup and retreiving a list of calendars.
All of that works, however when I try to retrieve calendar events, I get a bad request error and I am not sure how to solve it. Here is the code followed by the error message received when the script is run.
*NOTE: I AM TESTING THIS FROM MY MACHINE USING XAMPP
//GET LIST OF EVENTS
$index = 0;
foreach($listFeed as $list) {
$query = $service->newEventQuery($list->link[0]->href);
// Set different query parameters
$query->setUser('default');
$query->setVisibility('private');
$query->setProjection('full');
$query->setOrderby('starttime');
// Get the event list
try {
$eventFeed[$index] = $service->getCalendarEventFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getResponse() . "<br />";
}
$index++;
}
Here is the error message:
Error: HTTP/1.1 400 Bad Request Content-type: text/html; charset=UTF-8 Date: Mon, 14 May 2012 04:04:41 GMT Expires: Mon, 14 May 2012 04:04:41 GMT Cache-control: private, max-age=0 X-content-type-options: nosniff X-frame-options: SAMEORIGIN X-xss-protection: 1; mode=block Server: GSE Connection: close Invalid request URI
Thanks for your time and help.
$service->newEventQuery()
doesn't need a parameter here.
I believe you're retrieving calendar lists from a single user. Let's say it's yourself. So
$query->setUser('default');
won't help you get any second calendar, instead only the primary calendar which name is your email address.
Refer from Google developer protocol guide
To get a feed, you send the following HTTP request to Calendar, using the URL you found in the previous section of this document:
GET https://www.google.com/calendar/feeds/userID/private-magicCookie/full
So replace userID with your calendarID to get a particular calendar's event feeds.
Try
$index = 0;
foreach($listFeed as $list) {
$calendarID = $list->id->text;
$user = str_replace("http://www.google.com/calendar/feeds/default/owncalendars/full/", '', $calendarID);
$query = $service->newEventQuery();
// Set different query parameters
$query->setUser($user);
$query->setVisibility('private');
$query->setProjection('full');
$query->setOrderby('starttime');
// Get the event list
try {
$eventFeed[$index] = $service->getCalendarEventFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getResponse() . "<br />";
}
$index++;
}