At ReignDesign we use a shared Google Calendar to help plan our schedules. Todd previously wrote about Reigndesign's rabbit Nabby. What if there was a way to get Nabby to remind us about our upcoming appointments? Both Nabby and Google Calendar have simple APIs, and other folks have already written client libraries for PHP, so the amount of "glue" required to make it work was surprisingly small!
Ingredients

- One Nabaztag
- The Nabaztag PHP class by Aral Balkan
- The iCal PHP parser on github
Method
In Google Calendar, find the calendar you want your Nabaztag to make announcements for. Click the down arrow by the name and choose Calendar settings.

Then right click and copy the link for the iCal private URL.

Create a folder for your PHP project, and create a PHP file as follows:
/** Nabaztag-Google Calendar mashup! */ require("icalparser/SG_iCal.php"); //ical parser require("Nabaztag.class.php"); //nabaztag class - define your api key and secret in here $nabby=new Nabaztag; $parser=new SG_iCal('http://www.google.com/calendar/ical/.....'); //url of calendar $events=($parser->getEvents()); foreach ($events as $event) { $ttl=($event->getStart()-time())/60; if ($ttl>0 && $ttl<15) { //it's starting soon! $uid=$event->getUID(); if (!file_exists("uids/".$uid)) { //we haven't yet announced this event $data="Reminder: the event ".$event->getSummary()." is starting in ".round($ttl)." minutes"; //write to a file to avoid announcing twice file_put_contents("uids/".$uid,$data); //call the nabby api $nabby->talk($data,'US-Ernest'); } } }
This should be pretty self-explanatory. We loop through the events in the iCal document, looking for any events where the start time is in the next 15 minutes. If we find any, we send some text to the Nabaztag API to speak out loud. Then, we write to a file with the UID of the event to ensure we don't announce the same event several times.
A few housekeeping bits and pieces:
- create an empty uids folder
- on Linux you'll need to
chmod a+w uidsto ensure it's writable - set up a cronjob (Linux) or scheduled task (Windows) to run the PHP script as often as you want (say, every 2 or 5 minutes).
Success! A few minutes before your event is due, Nabby will now announce something like Reminder: the event "Lunch 2.0" is starting in 13 minutes.
Enjoyed this post? ReignDesign is a great team of tech-savvy developers providing RIA and mobile services. For more articles like this, subscribe to our blog feed.

Great idea! I was looking for something new to do with my rabbit, and Google calendar has replaced the old calendar on the ‘fridge in our house. I put together an implementation in python using the google calendar python api rather than ical. I set mine up just to read the events for the day once in the morning, but same concept.