Using the Bing Web Search API with ColdFusion

I've been working on this for a few hours, and don't seem to be getting anywhere fast! I've found plenty of examples for PHP, but none at all for ColdFusion. As far as I'm aware, I should be on the right track, but I keep getting an error returned.

My understanding (which, of course, may be wrong) is that I trigger the API with cfhttp and add a cfhttpparam for authorization. However, I'm not entirely sure what the header name should be - and I've tried quite a few!

Here's what I have right now;

<cfset acctkey = ToBase64("MYACCOUNTKEY")>

<cfhttp url="https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web?Query=%27MY_QUERY%27&Market=%27en-GB%27" method="get" resolveurl="yes">
<cfhttpparam type="header" name="Authorization: Basic " value="#acctkey#">
</cfhttp>

Every variation gives me the following error returned;

"The authorization type you provided is not supported. Only Basic and OAuth are supported"

I've also tried the following, with the same error;

<cfhttp url="https://user:#acctkey#@api.datamarket.azure.com/Bing/SearchWeb/v1/Web?Query=%27#url.q#%27&Market=%27en-GB%27" method="get">

The online docs (https://datamarket.azure.com/dataset/bing/searchweb) really don't seem to cover this outside of PHP and ASP - I can't even find a reference showing the header names that need to be passed!

Pointers would be much appreciated!


Purely through frustration, I now have this working. In a nutshell, it works if you DON'T Base64 encode, and you add username & password to the cfhttp tag, like so;

<cfhttp url="https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web?Query=%27MY_QUERY%27&Market=%27en-GB%27" method="get" username="MyACCOUNTKEY" password="MyACCOUNTKEY"> 
链接地址: http://www.djcxy.com/p/31224.html

上一篇: 登录并获取cookies使用CFHTTP

下一篇: 在ColdFusion中使用Bing Web Search API