bing搜索api php过滤器
我使用以下php连接到bing api: 如何添加过滤器(尺寸:小)? 代码来自bing文档,运行良好。 我正在使用此代码连接到bing并将响应重定向到iOS应用程序。 请帮忙bing搜索api php过滤器,php,api,filter,bing,Php,Api,Filter,Bing,我使用以下php连接到bing api: 如何添加过滤器(尺寸:小)? 代码来自bing文档,运行良好。 我正在使用此代码连接到bing并将响应重定向到iOS应用程序。 请帮忙 <?php { $accountKey = ‘XXXXXXXXX’; $auth = base64_encode("$accountKey:$accountKey"); $data = array( 'http' => array( 'request_fulluri' =&g
<?php
{
$accountKey = ‘XXXXXXXXX’;
$auth = base64_encode("$accountKey:$accountKey");
$data = array(
'http' => array(
'request_fulluri' => true,
'ignore_errors' => true,
'header' => "Authorization: Basic " . $auth));
$context = stream_context_create($data);
$query = isset($_GET['q']) ? $_GET['q'] : htmlspecialchars($_GET["searchtext"]);
$serviceOp = isset($_GET['sop']) ? $_GET['sop'] : 'Web';
$market = isset($_GET['market']) ? $_GET['market'] : 'en-us';
$ServiceRootURL = 'https://api.datamarket.azure.com/Bing/Search/';
$WebSearchURL = $ServiceRootURL . 'Image?$format=json&Image.Filters=+filterui:imagesize-large+filterui:photo-photo+filterui:face-face&Query=';
$request = $WebSearchURL . urlencode( '\'' . $query. '\'') ;
// Get the response from Bing.
$response = file_get_contents($request, 0, $context);
$jsonobj = json_decode($response);
// echo('<ul ID="resultList">');
header('Content-Type: application/json');
echo($response);
?>
首先从$WebSearchURL变量中删除所有图像过滤器,
然后使用以下方法添加图像过滤器:
$request = $WebSearchURL . urlencode( '\'' . $query. '\'').'&ImageFilters=';
$request = $request . urlencode( '\'' .'Size:Large+Face:Face'. '\'');
希望它能与您一起工作:)