I think that Twitter is pretty darn cool and would really like to be able to add a Twitter search box to my web site. In fact, I’d love to have some buttons that are pre-defined searches, like for the name of the latest movie in the theater or a celebrity too. Are those possible? I haven’t seen anyone do anything like that before…
Everything’s doable! The question is “how much of a nightmare would it be to add this?” and the good news is that the Twitter search system is incredibly easy to work with, and, better, it also has a sophisticated search engine so you can refine those buttons to filter out false matches (imagine the tons of false hits you’d get from the movie “Push”, for example).
It all starts with search.twitter.com and a bit of HTML knowledge.
What we’ll do is grab the URL from a search for those buttons, then reverse engineer the code needed to make their search box work and create an HTML code snippet that’ll offer the same functionality. Ready?
First off, go to search.twitter.com and search for “Avatar” as a test. You’ll end up with a Web page address (URL) like this:
That’s really all you need to create a rudimentary button: just use a graphic or text link and have that as the link. For example:
Avatar buzz on Twitter
Easy, eh? The source to that:
Without a detailed explanation, I’ll say that any time you see a URL of this type, you can also unwrap it and make it into a simple HTML form too:
<input type=”hidden” name=”q” value=”Avatar” />
<input type=”submit” value=”Avatar buzz on Twitter” /></form>
When we actually include this code, we get this:
Now, let’s turn that into a search box. It’s quite easy, actually, and the code looks almost identical:
<input type=”text” name=”q” />
<input type=”submit” value=”search Twitter” /></form>
Well, let’s add a prompt to it so you know what you’re typing in and move things around just a bit:
Search Twitter for: <input type=”text” name=”q” />
<input type=”submit” value=”go!” /></form>
Let’s see how that looks:
Nice, yes? From here you can tweak and fiddle to your heart’s content, but between the different ways I show to unwrap the search.twitter.com URLs you should be able to set up just what you want on your page!