在 Drupal 7 中使用 Bing 自定义搜索 API
Using Bing Custom Search API with Drupal 7
我们计划使用 Bing 搜索的托管 UI 版本,发现它仅支持查询参数 'q'。此参数不能与 Drupal 一起使用,因为它与同样为 'q' 的 Drupal 标准参数冲突。
我们是否仍然可以使用 Bing 搜索托管 UI 而无需更改 Drupal 参数 'q'?
谢谢
尝试使用 Bing search 模块。
它提供了一个搜索选项卡,可以从 Bing 网络服务中提取结果。可以将搜索查询限制为一组站点,并且可以使用各种高级搜索查询字符串(或附加到所有搜索查询)。
根据@user2574948 的上述评论重申正确答案。只需替换 YOUR_QUERY、YOUR_KEY 和 YOUR_CUSTOMCONFIG 即可。
$endpoint = 'https://api.cognitive.microsoft.com/bingcustomsearch/v7.0/search';
$term = 'YOUR_QUERY';
$headers = "Ocp-Apim-Subscription-Key: YOUR_KEY\r\n";
$options = array ('http' => array (
'header' => $headers,
'method' => 'GET'));
$context = stream_context_create($options);
$result = file_get_contents($url . "?q=" . urlencode($query) . "&customconfig=YOUR_CUSTOMCONFIG&responseFilter=Webpages&mkt=en-us&safesearch=Moderate", false, $context);
我们计划使用 Bing 搜索的托管 UI 版本,发现它仅支持查询参数 'q'。此参数不能与 Drupal 一起使用,因为它与同样为 'q' 的 Drupal 标准参数冲突。
我们是否仍然可以使用 Bing 搜索托管 UI 而无需更改 Drupal 参数 'q'?
谢谢
尝试使用 Bing search 模块。
它提供了一个搜索选项卡,可以从 Bing 网络服务中提取结果。可以将搜索查询限制为一组站点,并且可以使用各种高级搜索查询字符串(或附加到所有搜索查询)。
根据@user2574948 的上述评论重申正确答案。只需替换 YOUR_QUERY、YOUR_KEY 和 YOUR_CUSTOMCONFIG 即可。
$endpoint = 'https://api.cognitive.microsoft.com/bingcustomsearch/v7.0/search';
$term = 'YOUR_QUERY';
$headers = "Ocp-Apim-Subscription-Key: YOUR_KEY\r\n";
$options = array ('http' => array (
'header' => $headers,
'method' => 'GET'));
$context = stream_context_create($options);
$result = file_get_contents($url . "?q=" . urlencode($query) . "&customconfig=YOUR_CUSTOMCONFIG&responseFilter=Webpages&mkt=en-us&safesearch=Moderate", false, $context);