Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


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?


Dave's Answer:

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:

facebook-search-seo

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:

facebook-search-seo

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:

facebook-search-seo

Click on "Public Posts" and you'll see lots of results, particularly if it's a popular topic like The Hobbit:

facebook-search-seo

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:

facebook-search-seo

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!
    Enter your name: and your email addr:  




Categorized: Facebook Help , HTML, JavaScript and Web Site Programming   (Article 10582, Written by )
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:

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, Dave, for all your helpful information by buying you a cup of coffee!
Rather amazingly, there are no comments on this article yet.

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











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 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. Further, 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. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.