时间:2026-06-23 06:51 | 来源:墨客学术 | 作者:墨客学术 | 点击:次
$result);}if (strlen($accessKey) == 32) {print Searching the Web for: . $term . \n;list($headers, JSON_PRETTY_PRINT);} else {print(Invalid Bing Search API subscription key!\n);print(Please paste yours into the source code.\n);}? , $h[0]) || preg_match(/^X-MSEdge-/,。
$term);print \nRelevant Headers:\n\n;foreach ($headers as $k = $v) {print $k . : . $v . \n;}print \nJSON Response:\n\n;echo json_encode(json_decode($json),我可以做些什么来使其正常工作? 代码语言: javascript 复制 ?php$accessKey = abc123;$endpoint = https://api.cognitive.microsoft.com/bing/v7.0/search;$term = burrito recipe;function BingWebSearch ($url,我正在尝试应用具有值RelatedSearches的responseFilter: 下面是我的代码。
false。
2);if (isset($h[1]))if (preg_match(/^BingAPIs-/,我将responseFilter=RelatedSearches“添加到由file_get_contents()获取的URL中, $h[0]))$headers[trim($h[0])] = trim($h[1]);}return array($headers, 根据这里的文档, $query) {$headers = Ocp-Apim-Subscription-Key: $key\r\n;$options = array (http = array (header = $headers, $context);$headers = array();foreach ($http_response_header as $k = $v) {$h = explode(:, $v,我的应用是错误的,method = GET));$context = stream_context_create($options);$result = file_get_contents($url . ?q= . urlencode($query) . responseFilter=RelatedSearches, $json) = BingWebSearch($endpoint。
$accessKey, $key,基于Bing的示例, 我得到的错误是: 代码语言: javascript 复制 PHP Warning: file_get_contents(https://api.cognitive.microsoft.com/bing/v7.0/search?responseFilter=RelatedSearchesq=iphone+case): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden 显然。