Ask a questionAsk a question
 

General Discussioncalling Bing

All Replies

  • Wednesday, August 26, 2009 6:55 PMNikola Dudar [MSFT]MSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello,

    During PDC 2008, attendees could try building a client to Live Search APIs using WWSAPI. It is not exactly the same as Bing API, but the process is similar. These steps should work :

    a) Get AppID from http://www.bing.com/developers/

    b) Download metadata by running the command svcutil /t:metadata
    http://api.search.live.net/search.wsdl?AppID=<YourAppIDHere>, see API Basics for more details.

    c) Create service Proxy using the pre-generated template _CreateServiceProxy

    d) Fill out SearchRequest structure with a query for the information. Here is an example from PDC lab, change the parameters as needed
     

        // Form search request to Live Search

        SourceRequest srcRequest = { SourceTypeNews,

            0,

            100, // Specifies the number of results to be returned

            NULL,

            NULL,

            NULL,

            0,

            NULL};

     

        SearchRequest request =  { L"YOUR_APPLICATION_ID",

            queryString, // the actual query

            L"en-US",    // local

            SafeSearchOptionsModerate,

            NULL,

            NULL,

            1,

            &srcRequest};

     e) Call to function *_Search() using the structures you have formed
    f) The result will be stored in SearchResponse* pointer, which you can parse out. Here is how it was done in the lab:

       // Initializing response structure to where results of the search will be saved

        SearchResponse* response;

     

        // Call operation MSNSearchService.Search

        hr = MSNSearchPortBinding_Search(m_serviceProxy, &request, &response, m_heap, NULL, 0, NULL, m_error);

     

       // Parsing and outputing results

        SourceResponse* srcResponse = response->Responses;

        for (unsigned int iResponse = 0; iResponse < response->ResponsesCount; iResponse ++)

        {

            Result* srchResults = srcResponse[iResponse].Results;

            for (unsigned int iResult =0; iResult < srcResponse[iResponse].ResultsCount; iResult ++)

            {

                WCHAR* szTitle = srchResults[iResult].Title;

                OutputSearchResult(szTitle);

            }

        }

    Done. Give it a try and if it does not work out, just ask for help here.

    Regards,
    Nikola


    Nikola Dudar is the Program Manager for Windows Web Services API team. This post is provided "AS IS" with no warranties, and confer no rights. Use of any samples is subject to the terms specified at http://www.microsoft.com/ info/cpyright.htm