Industry guru Dave Taylor answers free tech support questions about a wide variety of business and technical topics, including blogging, Google AdSense, MySpace, Sony PSP, Apple iPod, Mp3 players, management, Linux, SEO, Mac OS X, Facebook, Twitter, LinkedIn and Microsoft Windows.

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!



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

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

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

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









Remember personal info?


Please note that I will never send you any unsolicited commercial 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.









Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Join the List!
Join my author info mailing list, where you'll learn about my upcoming books, speaking gigs, and more!


Book Links
© 2002 - 2008 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]