Hey everyone,
I posted a question about this last night, but I don't think it was clear enough.
I am using the Zend_Gdata package with PHP to add events to my Google Calendar. I can successfully add events.
However, when I add an event, I want to add that event's URL to a database so that if I ever need to delete that event, I can retrieve the event's URL to delete it (or modify it)...
Now, I have searched far and wide for how to do this, and no avail. From my post last night, I found that I should be using:
echo $event->getEditLink()->href;
I tried this, but nothing gets echoed. If I print("Event: $event..."), then the only thing printed is "Event", nothing about the URL.
If someone could please shed some light on what I'm doing wrong, I'd greatly appreciate it! Here is my code for adding an event:
function add_gcal($title, $date, $desc){
$newIncludePath = array();
$newIncludePath[] = '../ZendGdata-1.8.4PL1/library';
$newIncludePath = implode($newIncludePath);
set_include_path($newIncludePath);
// load classes
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');
// connect to service
$gcal = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$user = "[email protected]";
$pass = "------";
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $gcal);
$gcal = new Zend_Gdata_Calendar($client);
// construct event object
// save to server
try {
$event = $gcal->newEventEntry();
$event->title = $gcal->newTitle($title);
$event->content = $gcal->newContent($desc);
$when = $gcal->newWhen();
$when->startTime = $date;
$when->endTime = $date;
$event->when = array($when);
$gcal->insertEvent($event);
echo $event->getEditLink()->href;
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: Unable to add event to Google Calendar" . $e->getResponse();
}
}
EDIT:
Nevermind, I was able to figure it out. I think I was missing this line:
$newEvent->when = array($when);