首先,我对我的英语感到抱歉。 我正在用java开发一个应用程序,我想使用搜索Bing API,所以我打开了Bing的以用户为中心的开发( http://www.bing.com/dev/en-us/dev-center )并接受 key 号码,然后我编写了以下代码来获取结果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 Steps of creating appid for bing search
这里有一些问题可以帮助您: Bing search API and Azure
关于java - 必应 API 错误 1002,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21230173/