Hey Guys
I have been playing around with the google calendar API using the Zend Framework- Gdata library.
I have had mild success in using this and have stumbled accross an issue I beleive is to do with passing variables through a URL.
Basically, I can create several calendars and I want to create events for the chosen calendar. So, I chose the calendar I want and pass that calendar id ($vle_cal) through $_GET to a page where I can view all the events that exist for that calendar. On that page I click on an ADD EVENT link, which passes the calendar ID to a page where the even create form is. If I hard code the calendar ID then i can create events for whichever calendar I chose, but if I try and create the calendar using a variable I am pasing through, then the event is created for the default calendar.
calendar id = aab9e2amstkp5h4hp7v8rdctic@group.calendar.google.com
the hard coded URL is: //$url = 'https://www.google.com/calendar/feeds/aab9e2amstkp5h4hp7v8rdctic@group.calendar.google.com/private/full';
but when trying to insert the URL using a variable e.g
$gcal->insertEvent($event,$_POST.'/owncalendars/full']);
it doesn't insert into my chosen calendar. I have done an
echo $_GET; to make sure the calendar id is correct. But still it doesnt work.
Here is my code:
// connect to service
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $gcal);
;
$gcal = new Zend_Gdata_Calendar($client);
$vle_cal = $_GET['vle_cal'];
$url = 'https://www.google.com/calendar/feeds/'.$_GET['vle_cal'].'/private/full';
$title = htmlentities($_POST['title']);
// start form date mm/dd/yyyy
$form_date_start = $_POST['start_date'];
// end form date
$form_date_end = $_POST['end_date'];
// start date
$start_vle_m = substr("$form_date_start", 0, 2);
$start_vle_d = substr("$form_date_start", -7, 2);
$start_vle_y = substr("$form_date_start", -4, 4);
// end date
$end_vle_m = substr("$form_date_end", 0, 2);
$end_vle_d = substr("$form_date_end", -7, 2);
$end_vle_y = substr("$form_date_end", -4, 4);
$start = date(DATE_ATOM, mktime($_POST['sdate_hh'], $_POST['sdate_ii'], 0, $start_vle_m, $start_vle_d, $start_vle_y));
$end = date(DATE_ATOM, mktime($_POST['edate_hh'], $_POST['edate_ii'], 0, $end_vle_m , $end_vle_d , $end_vle_y));
// construct event object
// save to server
try {
$event = $gcal->newEventEntry();
$event->title = $gcal->newTitle($title);
$when = $gcal->newWhen();
$when->startTime = $start;
$when->endTime = $end;
$event->when = array($when);
//inser the new event
$gcal->insertEvent($event,$url);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getResponse();
}
echo 'Event successfully added!';
}
?>
If anyone can help shed some light on this for me then I would really appreciate it as I have been scratching my head for some time on this.
thanks very much