找到你要的答案

Q:Bing Search HTTP request with JSON result example?

Q:Bing搜索结果示例JSON请求?

Please help to figure out the parameters for Bing Search request that returns results in JSON. Document "Migrating Bing Search API Applications" tells us: "To authenticate a Bing Search API request with Windows Azure Marketplace, you must obtain an account key. This mode of authentication replaces the AppID used in the Bing Search API 2.0."

On the other hand the same document provides the following example that still uses Appid: http://api.search.live.net/xml.aspx?Appid=App&query=odata&sources=web&count=2

The following request: curl "https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Web?Query=%27xbox%27&$top=50&$format=json$accountKey=TPP....VRTWiq4=$Appid=conceptor"

Results in the following error: The authorization type you provided is not supported. Only Basic and OAuth are supported

Please give an example of search Bing URL that can be used in CURL command line to get search results in JSON format.

Please help to figure out the parameters for Bing Search request that returns results in JSON. Document "Migrating Bing Search API Applications" tells us: "To authenticate a Bing Search API request with Windows Azure Marketplace, you must obtain an account key. This mode of authentication replaces the AppID used in the Bing Search API 2.0."

On the other hand the same document provides the following example that still uses Appid: http://api.search.live.net/xml.aspx?Appid=App&query=odata&sources=web&count=2

The following request: curl "https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Web?Query=%27xbox%27&$top=50&$format=json$accountKey=TPP....VRTWiq4=$Appid=conceptor"

Results in the following error: The authorization type you provided is not supported. Only Basic and OAuth are supported

请举一个例子,搜索Bing的URL,可以用卷发命令行以JSON格式得到的搜索结果。

answer1: 回答1:

Now, you should only use datamarket.azure styled API calling. The old one cannot work any more. A big difference on authentication is that you don't need include your AppID in your query URL. A authentication window pops up and you need just provide your default account key (or any key you created in your account). See this very good summary of new Bing API

现在,你应该只使用datamarket.azure风格的API调用。老的不能再工作了。认证一个很大的区别是,你不需要包括您的查询网址AppID。一个验证窗口弹出,您只需要提供您的默认帐户密钥(或任何键,您创建在您的帐户)。看到这个很好的总结新的Bing API

answer2: 回答2:

You need to send your app key as a Base64 encoded string in the basic auth header.

Authorization: Basic {{ encoded_app_key }}

BTW The previous answer links to an overview of the old Bing api, hence not useful if you are on the data marketplace api.

Here is your example using jQuery.

$.ajax({
    type:'POST',
    url:url,
    headers: {
        "Authorization": "Basic " + encodedAppKey
    }
}).done(function(data) { 
    alert(data);
});

Useful link: http://social.msdn.microsoft.com/Forums/windowsazure/en-US/9f085915-81b6-488d-a348-1c3ca769d44f/migrating-to-windows-azure-bing-search-api-with-jquery-jsonp

你需要把你的应用程序的关键是Base64编码的字符串的基本认证。

Authorization: Basic {{ encoded_app_key }}

顺便说一句,以前的答案链接到旧的必应API的概述,因此不是有用的如果你在数据集市的API。

这是你的例子使用jQuery。

$.ajax({
    type:'POST',
    url:url,
    headers: {
        "Authorization": "Basic " + encodedAppKey
    }
}).done(function(data) { 
    alert(data);
});

有用的链接:http://social.msdn.microsoft.com/forums/windowsazure/en-us/9f085915-81b6-488d-a348-1c3ca769d44f/migrating-to-windows-azure-bing-search-api-with-jquery-jsonp

json  bing