Been busy working on a software licensing lately. Finally had the time to play with Zend’s standalone GData client library. I learnt about it through Dot Jay’s excellent article on sending SMS with Google Calendar on Twitter direct messages using PHP.
I gave it a go with his codes and realized quickEvent will not trigger a SMS alert. GCal SMS alerts are sent (latest) 5 mins before the event, creating an event now will “miss” that alert.
In other words, if you want an alert now, create an event that will occur 6 mins from now.
Translate that to code (largely from Dot Jay’s with my modifications), it looks something like this:
<?php
// Define credentials for the Google Calendar account
define(’GCAL_USER’, ‘yourid@gmail.com’);
define(’GCAL_PASS’, ‘yourpwd’);
// Include Zend GData client library
require_once ‘Zend/Loader.php’;
Zend_Loader::loadClass(’Zend_Gdata’);
Zend_Loader::loadClass(’Zend_Gdata_ClientLogin’);
Zend_Loader::loadClass(’Zend_Gdata_Calendar’);
// Get Google Calendar service name (predefined service name for calendar)
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
// Authenticate with Google Calendar
$client = Zend_Gdata_ClientLogin::getHttpClient(GCAL_USER, GCAL_PASS, $service);
// Create a new Google Calendar object
$calendar = new Zend_Gdata_Calendar($client);
// Create a new event
$event = $calendar->newEventEntry();
//setup reminder setting
$reminder = $calendar->newReminder();
$reminder->method = “sms”;
$reminder->minutes = “5″; //google even soonest sms reminder is 5 mins
$startDate = date(”Y-m-d”);
$startTime = date(”H:i”, time() + 6*60);//6 mins ahead of now
$endDate = date(”Y-m-d”);
$endTime = date(”H:i”, time() + 7*60);//7 mins ahead of now
$tzOffset = “+08″; //this is Singapore’s offset
$when = $calendar->newWhen();
$when->startTime = “{$startDate}T{$startTime}:00.000{$tzOffset}:00″;
$when->endTime = “{$endDate}T{$endTime}:00.000{$tzOffset}:00″;
$when->reminders = array($reminder);
$event->when = array($when);
// Add our message as the event content
$event->title = $calendar->newTitle(”My title”);
$event->content = $calendar->newContent(”TwitterSG alert”);
// Send the new event to be added to Google Calendar
if (defined(’GCAL_ID’)) {
$newEvent = $calendar->insertEvent($event, ‘http://www.google.com/calendar/feeds/’.GCAL_ID.’/private/full’);
} else {
$newEvent = $calendar->insertEvent($event);
}
?>
With this piece of code, it’s not hard to imagine the uses for it.

Entries (RSS)