簡體   English   中英

Bing API錯誤1002

[英]Bing API error 1002

首先,我對我的英語感到抱歉。 我正在用Java開發應用程序,並且想使用搜索Bing API,所以我打開了以用戶為中心的Bing開發( http://www.bing.com/dev/zh-cn/dev-center )並接受密鑰號然后我寫了下面的代碼來獲得結果Bing

String q = "http://api.bing.net/json.aspx?Appid=MyClientId=girls&sources=web&web.count=40&web.offset=41";

URL searchURL;
try {
    searchURL = new URL(q);
    HttpURLConnection httpURLConnection = (HttpURLConnection) searchURL.openConnection();

    if(httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK){
        InputStreamReader inputStreamReader = new InputStreamReader(httpURLConnection.getInputStream());
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader, 8192);

        String line = null;
        String result = "";
        while((line = bufferedReader.readLine()) != null){
            result += line;
        }

        bufferedReader.close();
    }
} catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

為什么會出現以下錯誤1002?

{"SearchResponse":{
    "Version":"2.2",
    "Query":{"SearchTerms":"girls"},
    "Errors":[
        {"Code":1002,
         "Message":"Parameter has invalid value.",
         "Parameter":"SearchRequest.AppId",
         "Value":"MyClientId",
         "HelpUrl":"http:\/\/msdn.microsoft.com\/en-us\/library\/dd251042.aspx"}]
}}

您的地址似乎有錯字,這看起來非常可疑:

Appid=MyClientId=girls

您應該看到文檔http://msdn.microsoft.com/en-us/library/dd250882.aspx ,但是我想您需要將MyClientId替換為某些內容,並且也沒有冒出查詢和clientId即&q=girls

編輯:您需要在某處獲取AppId 為bing搜索創建appid的步驟

以下問題可以為您提供幫助: Bing搜索API和Azure

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM