0

I am trying to shift my Bing API from old one to new Windows Azure Marketplace

My code is like this:

String serviceUrl = "https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/
                    v1/Web?Query='"+ query+"'";

byte[] accountKeyBytes = Base64.encodeBase64(( bingAzureApiKey + ":" + 
       bingAzureApiKey).getBytes());
String accountKeyEnc = new String(accountKeyBytes);

URL celebSearchurl = new URL(serviceUrl);
URLConnection urlc = celebSearchurl.openConnection();
urlc.addRequestProperty("Authorization", "Basic "+accountKeyEnc);
urlc.setConnectTimeout(2500);
urlc.setReadTimeout(2500);

But I am getting 400 error for the same. I am failing to understand what am I doing wrong here?

4

1 回答 1

0

我在 Google Code 上启动了一个项目,以便更轻松地使用新的 Azure 实现。看看它是否有帮助。

http://code.google.com/p/azure-bing-search-java/

<%
AzureSearchNewsQuery aq = new AzureSearchNewsQuery();
aq.setAppid(AZURE_APPID);
aq.setQuery("Oklahoma Sooners");

aq.doQuery();
AzureSearchResultSet<AzureSearchNewsResult> ars = aq.getQueryResult();
for (AzureSearchNewsResult anr : ars){
        %>
        <h2><%=anr.getTitle()%> (<%=anr.getSource() %>)</h2>
        <p><%=anr.getDate() %></p>
        <p><%=anr.getDescription() %></p>
        <a href="<%=anr.getUrl() %>"><%=anr.getUrl() %></a>
<%}%>
于 2012-08-05T07:54:28.520 回答