Bing API PHP

Get the new updates at the project homepage in codeplex.

Well, since the opening of bing.com I’ve been playing with the API and some of the options it provides. Certainly I was getting annoyed since I had to rebuild each of my queries if I wanted something so I search for a library that could do this for me which I couldn’t find and I ended up writing my own.

Requirements: PHP5 and cURL

How to use this API? Here is a simple demonstration


// Include the Bing API PHP Library
require_once 'library/BingAPI.php';

// Simply start the class with your AppID argumented
$search = new BingAPI('YOUR APPID KEY');

// Build your query easily
/* To use multiple resources simply do ->setSources('Web+Image') ,
   it must match the source type
   bling.com provides */
$search->query('gimp')
       ->setSources('Web')
       ->setFormat('xml') /* Also you can try: xml, soap or json */
       ->setOptions(
             array(
                  'Web.Count' => '10',
                  'Web.Offset' => '0',
                  'Adult' => 'Moderate',
                  'Options' => 'EnableHighlighting')
    );
/* Check the API documentation in bing.com for more information */

/* This will give you a raw output */
echo $search>getResults();

I’d hope this little library makes your life easier :) Soon there’ll be a tracker if there are problems with it or you can comment here.

Download it now | Check the documentation | Get a Developer API Key

Heads up: There will be soon a better way to issue bugs

Any issues: http://bingapiphp.codeplex.com/WorkItem/List.aspx
Project Homepage

About SOAP Implementation

It seems I have made silly mistake with SOAP, there is actually no current SOAP implementation and it will be supplied soon.

12 people like this post.
This entry was posted in PHP, Programming, Projects. Bookmark the permalink.

11 Responses to Bing API PHP

  1. TuVinhSoft says:

    Wow. Very useful PHP Lib. I will download and try to use it. Of course will tweet this.

  2. Pingback: API para bing | rhypee 2.0

  3. Pingback: Edgar A. Ronda

  4. Pingback: » API PHP para Bing

  5. Funthomas says:

    It is cool, congratulation.

  6. Pingback: Using APIs With PHP? Here Are Your Classes | Jeez Tech

  7. linuxer says:

    what about version 2?

    • David says:

      As in releasing a new version? Don’t know, hard to say since I’m not really motivated to extend it. The source is free to fork since it’s under the MIT license :)

  8. Sergey says:

    My friend, you have to urlencode() the query before putting it to the query string.
    Searching for more then one word will result in “400 Bad request” from Bing.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>