Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
bing搜索api php过滤器_Php_Api_Filter_Bing - Fatal编程技术网

bing搜索api php过滤器

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连接到bing api: 如何添加过滤器(尺寸:小)? 代码来自bing文档,运行良好。 我正在使用此代码连接到bing并将响应重定向到iOS应用程序。 请帮忙

 <?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'. '\'');
希望它能与您一起工作:)