none
Bing Search API, trying to search but get nothing

    Question

  • I subscribed the bing searh api - web result only. However, when I tried the code example (PHP) inside the document of "Bing Search API Quick Start and Code Sample.docx" and the one inside "ADM Migration Guide.docx", I got nothing from the response.

    You can try the two example here:

    cheapsubmit.net/test.php cheapsumit.net/bingapi.php

    For the first, I didn't use the form but just directly assigned the values and using the added account key.

    For the second, I'm using the same and the primary key of my account.

    When I tried to print out the json object by var_dump($jsonObj), the thing I got is NULL.

    I tried the service explorer to experiement the url, but got bad request error.

    Can anybody figure out what's wrong?

    Friday, March 07, 2014 3:35 AM

Answers

  • Problem solved by making several modifications as below:b

    1. For web results only, the url shall be as: api.datamarket.azure.com/Bing/SearchWeb, and api.datamarket.azure.com/Bing/Search not working for this subscription;
    2. The auth base64_encode($accountKey . ":" . $accountKey) shall be changed to base64_encode(":" . $accountKey), some forums will suggest you change to to base64_encode("ignored:" . $accountKey) or base64_encode("username:" . $accountKey), both not working. Just leave the username as empty;
    3. You shall put the query string inside single quotes like "....Query='" . urlencode($querystring) . "'";

    Maybe the start guide isn't for web results only subscription. Can't understand why they don't make it clear and give developers so many trouble.

    Sunday, March 09, 2014 8:28 AM

All replies

  • hi,

    I guess a few reason may be due to this question.I recommend you could refer to this thread and try the code (http://stackoverflow.com/questions/10844463/bing-search-api-and-azure/10844666#10844666 ). Also, you could refer to this code sample (http://www.phpclasses.org/browse/file/42007.html ).

    Please try it. 

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 07, 2014 9:45 AM
  • Problem solved by making several modifications as below:b

    1. For web results only, the url shall be as: api.datamarket.azure.com/Bing/SearchWeb, and api.datamarket.azure.com/Bing/Search not working for this subscription;
    2. The auth base64_encode($accountKey . ":" . $accountKey) shall be changed to base64_encode(":" . $accountKey), some forums will suggest you change to to base64_encode("ignored:" . $accountKey) or base64_encode("username:" . $accountKey), both not working. Just leave the username as empty;
    3. You shall put the query string inside single quotes like "....Query='" . urlencode($querystring) . "'";

    Maybe the start guide isn't for web results only subscription. Can't understand why they don't make it clear and give developers so many trouble.

    Sunday, March 09, 2014 8:28 AM