2

我正在尝试为我的应用程序使用 Bing API。到目前为止,我正在使用不同网站上提供的示例代码。但每次我遇到同样的错误。

我不了解错误的含义。我正在使用本地主机中的此代码,这可能是个问题吗?

[代码] => 1002

[消息] => 参数值无效。

[参数] => SearchRequest.AppId

[值] => VSwhx6yl2AOlvvTILBIhbJnWO8h0hQ5LoJkGqKp8OCY=

[HelpUrl] => http://msdn.microsoft.com/en-us/library/dd251042.aspx

我试着用谷歌搜索答案,很多人都有同样的问题,但我无法从论坛和讨论中得到答案。我使用的代码如下:

<body>
<?php
    $search = trim($_POST['search']);
    if($_POST['submit']) {
        if(strlen($search) == 0) {
            echo "<p>Error: empty search</p>";
        }
        else {
            $get = file_get_contents("http://api.bing.net/json.aspx?AppId=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&Query=".urlencode($search)."&Sources=Web&Web.Count=15");
            $decode = json_decode($get, TRUE);
            echo "<pre>";
            print_r($decode); // let's print it in a more readable format
            echo "</pre>";
        }
    }
?>
<div style='text-align: center'>
<h1>Search - powered by Bing</h1>
<form method="post" action="index.php">
    <input type="text" name="search" size="50" />
    <input type="submit" name="submit" value="Bing" />
</form>
</div>
</body>
4

1 回答 1

0

通过查看您的代码,您使用的是旧 API,您必须使用新的 Bing API。请参阅此链接。该 API 已弃用。您必须使用 azure bing API。

于 2013-01-16T16:12:04.057 回答