无法弄清楚如何查询兵/ Azure的市场API [英] Can't figure out how to query Bing/Azure Marketplace API

查看:140
本文介绍了无法弄清楚如何查询兵/ Azure的市场API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何赫克你使用Bing API(现在Azure的市场API)?它是否只支持OAuth的?谁能告诉我如何验证到它的一个例子吗?该文档是沉默和无奈的一个小时后,我在这里张贴的问题。

How the heck do you use the Bing API (now Azure Marketplace API)? Does it only support oAuth? Can anyone show me an example of how to authenticate to it? The documentation is silent and after an hour of frustration I'm posting the question here.

下面是终点,我试图打:

Here is the end point I am trying to hit:

<$c$c>https://api.datamarket.azure.com/Bing/Search/v1/Composite?query=sushi&sources=web

这抛出了基本身份验证;如果我取消我得到一个错误信息说,只有基本和OAuth的支持。

This throws up Basic Auth; if I cancel I get an error message saying that only Basic and oAuth are supported.

但是,没有已知的到我的帐户的用户名和密码的组合,适用于基本的,我无法找到如何使用OAuth与它的例子。我已经建立了一个帐户,我已经订阅了自由层。

However, no combination of username and password known to my account works for Basic, and I can't find an example of how to use oAuth with it. I have an account set up, I have subscribed to the free tier.

推荐答案

做更多的研究和实验后,我能弄明白。这些例子困惑我(我想theyassume很多方面的有关天青的肥皂水约定通过REST,如大小写和引用字符串)。也许他们会迷惑别人,所以我在这里张贴我的答案是:

After doing more research and experiment I was able to figure it out. The examples confused me (I think theyassume a lot of context about Azure's SOAPy conventions over REST, such as case sensitivity and quoted strings). Perhaps they will confuse others so I'm posting my answer here:

function searchBing() {
    var request=require('request');
    var url="https://api.datamarket.azure.com/Bing/Search/v1/Web?Query='sushi'&$format=JSON";
    var key="[your account key]";
    request.get(url, {auth: { user: key, password: key} }, function (error, result) {
        console.log(error, result.body);
    })
}

这篇关于无法弄清楚如何查询兵/ Azure的市场API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆