|
|
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 challenge: is there a way to add a Facebook search box on my blog or web site? If so, what's the HTML code needed? That's an interesting puzzle because generally Facebook is a closed world, a "walled garden", as they say, so theoretically it should be impossible to just drop someone smack dab into the middle of things after they've entered a search on your page. But then again, if you do a search and look at the resultant URL, there's a tantalizing hint that it might just be possible... On the other hand, it will require that the user have a Facebook account and be logged in to their account simultaneously (which is hardly a problem since the majority of the billion Facebook users check their newsfeed multiple times each day, so that's probably not much of an issue. Further, there's some confusion about how much of the Facebook information is accessible for someone who doesn't have an account, or is logged out. Then again, we can test that, can't we? Let's do a basic search box, first of all. And that brings up an interesting point because most people really don't have a clue about how sophisticated the Facebook search system is and that they see over one billion searches each day. Impressive! When you are on Facebook, the search box sits unadorned along the top: You probably only use it to search for people, but it's a full blown search box! For example, a search for "The Hobbit" produces a bunch of interesting results: ![]() The most important thing is the very bottom link, "See more results...". Click on it and you'll get a page full of results. But ignore them. Instead, look at the many filters available to constrain your results. It's on the left: ![]() Click on "Public Posts" and you'll see lots of results, particularly if it's a popular topic like The Hobbit: ![]() We can work with that, but let's instead build a search box based on the "Posts by Friends" option. A click on that and I see a Hobbit-related note from my friend Aaron: ![]() More importantly, the URL associated with that result looks like this: https://www.facebook.com/search/results.php?q=the%20hobbit&type=fposts&init=quick&tas=0.9916121198330075
Turns out that with a tiny bit of experimentation it becomes clear that the last two name=value pairs are unnecessary, which reduces the URL to the succinct: https://www.facebook.com/search/results.php?q=the%20hobbit&type=fposts
Now it's just a matter of unwrapping it and rebuilding it as an HTML form. Like this: <form method="get" action="http://www.facebook.com/search/results.php">
<input type="text" name="q" /> <input type="hidden" name="type" value="fposts" /> <input type="submit" value="Search Facebook" /> </form> It's not pretty, but it works. Here, try it: You can clean it up and make it fancy with just a bit of CSS styling, fortunately, so here's some better code to try: <form style="margin-left:0.25in;border:2px solid #666;padding:9px;border-radius:6px;background-color:#eee;" method="get" action="http://www.facebook.com/search/results.php">
<input type="text" name="q" size="50" /> <input type="hidden" name="type" value="fposts" /> <input type="submit" value="Search Facebook" /> </form> Which looks like this: Better? From this point, if you want to have the search be for public posts, simply change the hidden variable from "fposts" to "eposts". Easy enough!
More Useful Facebook Help Articles:
✔ How can I block event invites on Facebook?
I have a friend who keeps inviting me to webinars where he pitches his make-money programs. I really like the guy, but hate...
✔ Shortcut for blocking games on Facebook?I saw your article from a while back about blocking Coasterville notifications on Facebook and was wondering if you had a shortcut or...
✔ Update Facebook profile picture without notifying friends?Hey Dave! Whenever I change my profile picture on Facebook all my friends are notified of this change. Not good. How do I...
✔ How do I permanently block CoasterVille on Facebook?My brother is really into Facebook games and the latest that he seems obsessed with is called CoasterVille. I think it's all about...
✔ Disable audio notification sound in Facebook?This is something new: When I'm logged in to Facebook I now get an annoying audio beep every time someone posts something new...
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:
Facebook Help
,
HTML, JavaScript and Web Site Programming
(Article 10582,
Written by Dave Taylor)
Tagged: facebook search, facebook search results, facebook seo, html form programming, the hobbit Previous: What's a used computer really worth? Next: How do I block an iPad app from accessing Twitter? 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+ |