Bing Search API v5无效 [英] Bing Search API v5 not working

查看:69
本文介绍了Bing Search API v5无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哈,伙计,b
$
为了让Bing API工作,我已经花了很长时间了。我有以下代码,但它返回:

Ha guys,

I have been struggeling for quite a while now to get the Bing API working. I have the following code, but it returns:

{ "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }

任何人都可以帮我入门,以及如何让它工作?在我的Microsoft Azure中,我有:

Could anyone please help me getting started and on how to get this to work? In my Microsoft Azure I have:

1。订阅ID

2。访问键1

3。访问键2

这就是我现在所拥有的一切。真的希望有人可以帮助我:)

That's all I have at this point. Really hope someone can help me out :)

祝你好运

<?php
$url = 'https://api.cognitive.microsoft.com/bing/v5.0/search?q='.urlencode('apples');

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    "Content-Length: ".strlen($url),
    "Ocp-Apim-Subscription-Key: xxxxxxxx-82b2-4a78-a4d5-xxxxxxxx",
));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);

$answer = curl_exec($curl);

curl_close($curl);

echo '<pre><code>'.print_r($answer, true).'</code></pre>';
?>

推荐答案

您好,

我很遗憾听到您遇到此问题。  您的订阅密钥似乎存在问题。

I'm sorry to hear you are running into this problem.  There seems to be an issue with your subscription key.

您能否请先测试您的订阅密钥  测试控制台

Can you please test your subscription key in out testing console.

您可以使用Bing Search API订阅的密钥1或密钥2。

You can use key 1 or key 2 of your Bing Search API subscription.

Raymond


这篇关于Bing Search API v5无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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