none
Total Number of Results Bing Search API RRS feed

  • Question

  • Hi

    how to reach number of total results when using Bing Search API

    I can reach title, url and descripton but not totals. If I am right, metadata contains the Total results but how to reach it through json object?

    MY CODE:

    $response = file_get_contents($request, 0, $context);
    $bing_json = json_decode($response);
    echo "<br/> TOTAL";
    echo ($bing_json->Total);//????????????
    echo "<br/>


    Thank  you
    • Edited by dom007X Thursday, July 12, 2012 8:00 AM
    Thursday, July 12, 2012 7:59 AM

Answers

All replies

  • I don't know PHP. But to obtain the total results, you have to make a composite query. For exmaple, https://api.datamarket.azure.com/Data.ashx/Bing/Search/Composite?Sources=%27web%27&Query=%27Test%27&$format=Json will return the total results of web search on term "Test". Look into the WebTotal field in the result. If you want to obtain other search results, such as image, change the Sources parameter.

    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Friday, July 13, 2012 2:16 AM
    Moderator
  • Hi

    Thank you for fast reply :)

    When I replaced my url with your was working fine.I could see the WebTotal when print_r json object.

    However when I try to implement in my code:

    $WebSearchURL = $ServiceRootURL.'https://api.datamarket.azure.com/Data.ashx/Bing/Search/Web?$format=json&Query=%27Test%27&$top=10';

    I cannot see the WebTotal anymore or reach it to store in variable for similarity rank.

    I am obviously missing something here.

    Please could you tell me what is wrong with my request?

    Thank you



    • Edited by dom007X Friday, July 13, 2012 9:57 AM
    Friday, July 13, 2012 9:56 AM
  • As pointed out above, you need a composite query, instead of a web query. So replace Web by Composite in your URL, and add Sources=%27web%27 if you only ant to display web search results.

    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Thursday, July 19, 2012 2:22 AM
    Moderator