none
Bing Service报错 RRS feed

  • 问题

  • 我在Metro应用里,访问Bing,出现以下错误。如何消除错误?

    BingService bing = new BingService();  //出错
    SearchRequest request = new SearchRequest();
    request.AppId = "(my app id)";
    request.Sources = new SourceType[] {SourceType.Web};         
    SearchResponse response = bing.Search(request);
    。。。。。。

    2012年5月27日 4:40

答案

  • 您好!

    不知道你的应用具体报的什么错。

    请参考以下访问Bing的样例代码。

    string requestString = "http://api.bing.net/xml.aspx?"
                // Common request fields (required)
                + "AppId=" + AppId // your registered App ID
                + "&Query=msdn blogs"
                + "&Sources=Web"
                // Common request fields (optional)
                + "&Version=2.0"
                + "&Market=en-us"
                + "&Adult=Moderate"
                + "&Options=EnableHighlighting"
                // Web-specific request fields (optional)
                + "&Web.Count=10"
                + "&Web.Offset=0"            + "&Web.Options=DisableHostCollapsing+DisableQueryAlterations";
    
    // Create and initialize the request.
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestString);
    ......
    // Load the response into an XmlDocument.
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    XmlDocument document = new XmlDocument();
    document.Load(response.GetResponseStream());
    ......
    

    另外,你可以参考访问Bing的样例程序 http://msdn.microsoft.com/en-us/library/dd250950


    Best wishes,


    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年5月27日 6:02
    版主