|
|
Can I have a Twitter search box / button on my site?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: http://search.twitter.com/search?q=Avatar
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: Easy, eh? The source to that: <a href="http://search.twitter.com/search?q=Avatar">Avatar buzz on Twitter</a>
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: <form method="get" action="http://search.twitter.com/search">
<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: Cool, yes? Now, let's turn that into a search box. It's quite easy, actually, and the code looks almost identical: <form method="get" action="http://search.twitter.com/search">
<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: <form method="get" action="http://search.twitter.com/search">
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!
More Useful HTML, JavaScript and Web Site Programming Articles:
✔ How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔ Can I embed a Facebook search box on my blog site?I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔ Can I use CSS for drop shadows on my blog?I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔ How can I embed interactive photo panoramas on my site/blog?I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔ How can I create a Twitter search URL shortcut?I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...
Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help
right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
Categorized:
HTML, JavaScript and Web Site Programming
,
Twitter, LinkedIn and Social Network Help
(Article 9324,
Written by Dave Taylor)
Tagged: cgi, html forms, twitter, twitter search Previous: What kind of MacBook Pro do I need to run Final Cut Studio? Next: My LG Cellphone is locked and needs a PUK code. Help! Reader Comments To Date:
Rather amazingly, there are no comments on this article yet.
I do have a comment, now that you mention it!Check This Out Too... |
Recent Entries
Look for Answers
Recommended
All Our Categories
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and Blogging Building Web Site Traffic Business and Management Computer and Internet Basics d) None of the Above Facebook Help Google Gmail Help Google Plus Help HTML, JavaScript and Web Site Programming Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Kindle Fire Help Mac OS X Help Pay Per Click (PPC) Advertising Pinterest Help Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help Find Me on Google+ ADT on G+ |