Free tech support / small logo


Can I add Public Google Calendar Search to my site?

I'm intrigued by Google Calendar's public calendar search capability and am wondering if there's any way to reverse engineer it and add it to my own site. Possible?


Dave's Answer:

Of course. Just about any form can be reverse engineered if you have the patience to unwind the code that's inside a given page. In this case, you're talking about Google Calendar's public calendar search capability:

Google Calendar, Public Search

Here's what you want to do, however. Enter a rudimentary keyword like "music" and click on "Search Public Events", at which point you now get a more sophisticated search:

Google Calendar, Public Search #2

Rather than crack open the code, we can simply do a search and examine the resultant URL. Enter "music" as the search term, "denver" as the location and "today" as the time, and it produces a list of music venues in Denver, Colorado. But more importantly, the URL of that page is:

http://www.google.com/calendar/events?state=mode%3Dlist%2C1%26date%
3D20070413&q=music&btnG=Search+Public+Events&ql=denver&qt=&qtd=today

Let me make this a bit clearer by highlighting the words we searched for in bold:

http://www.google.com/calendar/events?state=mode%3Dlist%2C1%26date%
3D20070413&q=music&btnG=Search+Public+Events&ql=denver&qt=&qtd=today

As an experiment, I'll strip out all the name=value pairs that don't have specific information I've entered in my original search, which reduces it down to:

http://www.google.com/calendar/events?q=music&ql=denver&qtd=today

Surprise, that works just as well (copy and paste that into the Location box of your Web browser). Better, we can now reverse engineer it further and recognize that what we're really seeing here is:

Target URL: http://www.google.com/calendar/events
Query string: q=music
Location: ql=denver
Date: qtd=today

Armed with that information, it's simple to pour that into a rudimentary HTML form:

<form method="get" action="http://www.google.com/calendar/events">
Query: <input name="q"><br />
Location: <input name="ql"><br />
Date: <input name="qtd"><br />
<input type="submit" />
</form>

It ain't pretty, but it'll work. Try it:

Query:
Location:
Date:

That's not very attractive, but it does work! We can also use that same URL to embed searches into your text too, as demonstrated here:

And an inline example too: <a href="http://www.google.com/calendar/events?q=blues&qtd=this+week&ql=denver%2C+co" target="_blank">Blues events this week in Denver</a>. Simple enough.

Which would look like this: Blues events this week in Denver.

Finally, here's a really fancy version of this form that demonstrates how you can turn one or more fields into hidden variables and simplify the form for your own uses:

<form method="get" action="http://www.google.com/calendar/events">
<div style="border:1px solid #999;width:400px;padding:6px;background-color:#cce;">
<div style="background:#000;color:#fff;padding:4px;font-size:150%;
margin-bottom:10px;">Dave's Denver Event Calendar</div>
Looking for a concert, band, dance, theatrical review or other
event here in the beautiful Denver metro area? No worries, I can
help you find it!
<br /><br />
<table border="0">
<tr><td align="right">Event name or category:
</td><td>
<input type="text" name="q" />
</td></tr><tr><td align="right">
and your time range:
</td><td>
<input type="text" name="qtd" value="today" />
</td></tr></table>
<br />
<input type="hidden" name="ql" value="denver, co" />
<center>
<input type="submit" value="Ready? Let's find it!" />
</center>
</div>
</form>

Formatted and interpreted, it looks like this:

Dave's Denver Event Calendar
Looking for a concert, band, dance, theatrical review or other event here in the beautiful Denver metro area? No worries, I can help you find it!

Event name or category:
and your time range:

Hope that helps you get going with your reverse engineering project!









Subscribe!
Never miss another Q&A article! Click to subscribe: Add to Google Reader Add to My Yahoo! Subscribe in NewsGator RDF XML
Comments

I'm loving this article! I would never have been able to reverse engineer something like this. I'm trying to modify it to suit my needs, however, and am having troubles. I want to limit the search to a specific set of calendar events to which I've added a unique keyword. Is it even possible to allow the user to add in his/her own "q" but also add a hidden "q"? What I really want to do is to be able to search just a specific calendar, but Google doesn't allow that yet, or at least not as I've found. Ideas? Lost cause?

Posted by: Kelly at May 1, 2007 9:25 AM

hey dave almost everything you search for on the net for codes and help leads to myspace setups and codeings. all i want is a comment box like you have here...where all people commenting is in private and goes only to a specific email that i will set up..i will want to change the codes to match my site page...including buttons...id like to set it up just like i have my jump boxes and music box. ive been searching for help to do this and finally came across yours and thought maybe you can help me. ty

Posted by: razzy at May 4, 2007 6:25 AM

The empire of IT soloutions.

Posted by: Purushottam Sanjiv Kumar at November 1, 2007 4:14 AM

Hi how ru where ru ,......................

Posted by: lovely at June 12, 2008 12:27 AM

Google appears to have shut down this back door into calendar search. I cannot see a way to search calendars now without providing a Google login.

Posted by: G-Money at January 6, 2009 8:05 AM

Is it possible to add, edit or delete events to the public calendar by every one.

Posted by: Keeth at June 27, 2009 5:10 AM

is it possible visitors of my site add events to
google calender via my site just add not edit?

Posted by: shahram at October 8, 2010 12:20 PM

I have something to say, now that you mention it, but ...
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you for all your efforts on this Web site by buying you a cup of coffee!

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Recent Entries


Search
I Need Help!
Need Help? Ask Dave Taylor!


© 2002 - 2012 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.