Bing search API and Azure

后端 未结 7 903
滥情空心
滥情空心 2020-12-01 04:31

I am trying to programatically perform a search on Microsoft Bing search engine.

Here is my understanding:

  • There was a Bing Search API 2.0 , which will
相关标签:
7条回答
  • 2020-12-01 05:19

    Here is the example of how to call Bing/Azure API using Unirest library.

    require_once '/path/to/unirest-php/lib/Unirest.php';
    
    $accountKey = "xxx";
    $searchResults = Unirest::get("https://api.datamarket.azure.com/Bing/Search/v1/Composite",
        array(),
        array(
            'Query' => '%27Microsoft%27',
            'Sources' => '%27web%2Bimage%2Bvideo%2Bnews%2Bspell%27',
            '$format' => 'json',
        ), $accountKey, $accountKey
    );
    
    // Results are here:
    $objectArray = $searchResults->body->d->results;
    $rawJson = $searchResults->raw_body;
    

    You can omit Source parameter by defining it in the URL: https://api.datamarket.azure.com/Bing/Search/v1/Webor https://api.datamarket.azure.com/Bing/Search/v1/Image

    Note: parameters in request URL are case-sensitive. For Bing they start with a capital letter.

    0 讨论(0)
提交回复
热议问题