{"id":4355,"date":"2009-06-22T22:04:09","date_gmt":"2009-06-23T05:04:09","guid":{"rendered":"http:\/\/wapreview.com\/?p=4355"},"modified":"2009-06-23T07:26:49","modified_gmt":"2009-06-23T14:26:49","slug":"how-to-use-the-bing-api-to-search-the-mobile-web","status":"publish","type":"post","link":"https:\/\/wapreview.com\/4355\/","title":{"rendered":"How to Use the Bing API to Search the Mobile Web"},"content":{"rendered":"
<\/p>\n
When Microsoft released the Bing API I speculated<\/a> that it should be possible to use it to build a real Mobile Web search engine.\u00a0 By “real” I mean one that would search exclusively for mobile optimized Websites.\u00a0 I finally got around to trying it today, it was pretty easy, thanks to some some sample code I found on the Bing Developer Website, and it\u00a0 works surprisingly well.<\/p>\n I wrote my search engine in PHP5.\u00a0 It uses Bing’s JSON API.\u00a0 I first\u00a0 construct a URL containing my Bing API key and the query parameters. The URL looks like this:<\/p>\n http:\/\/api.search.live.net\/json.aspx?Appid=<Your Bing API Key>&sources=MobileWeb&query=<The Query String><\/em><\/p>\n “&sources=MobileWeb”<\/em> is the magic incantation that makes Bing return exclusively Mobile Web results. I pass the URL that I built\u00a0 to\u00a0 Bing with PHP’s curl_exec().\u00a0 Bing returns serialized JSON which I parse with another PHP5 function,\u00a0 json_decode().<\/p>\n Incidentally, in my original piece I wrote that the Bing API has “no usage limits and no restrictions on ordering and blending results”.\u00a0 This is incorrect, you are restricted to calling the API seven times per second, you can only reorder web (not mobile web) results and if you blend Bing results with results from other sources you must identify which ones come from each source.<\/strong> Still Bing seems to\u00a0 have the most permissive API of the Big Three search engines. It’s free to use, you can add your own banner ads to results and it’s the only one that lets to to restrict results to the mobile web. There’s a good “plain English” version of the TOS at the end of\u00a0 this document http:\/\/www.bing.com\/developers\/s\/API Basics.pdf<\/a> which is also a good introduction to the API.<\/p>\n You can download a copy of my working source code from here: bing.zip<\/a>. You need to replace “<Bing API Key>” at the top of the script with your own API key which you can obtain instantly from www.bing.com\/developers<\/a>.<\/p>\n If you just want to try it out, visit wapreview.mobi\/bing.php<\/a>.\u00a0 Consider it a proof of concept, it’s lacking in eye candy and needs\u00a0 more error handling before I’d\u00a0 call it production ready, but\u00a0 seems to work well for “normal” queries.<\/p>\n","protected":false},"excerpt":{"rendered":" When Microsoft released the Bing API I speculated that it should be possible to use it to build a real Mobile Web search engine.\u00a0 By “real” I mean one that would search exclusively for mobile optimized Websites.\u00a0 I finally got around to trying it today, it was pretty easy, thanks to some some sample code I found on the Bing Developer Website, and it\u00a0 works surprisingly well. I wrote my search engine in PHP5.\u00a0 It uses Bing’s JSON API.\u00a0 I … Continue reading