不,沒有辦法按圖片格式進行過濾。你可以這樣做,但(PHP):
$word = 'monitor';
$extension = 'jpg';
$request = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&Query=%27'.urlencode($word).'%27&Adult=%27Strict%27&ImageFilters=%27Size%3AMedium%2BAspect%3AWide%2BColor%3AColor%2BStyle%3APhoto%27';
$process = curl_init($request);
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($process, CURLOPT_USERPWD, "$accountKey:$accountKey");
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($process);
$json = json_decode($response, true);
if(is_array($json['d']['results'])) {
foreach($json['d']['results'] as $image) {
if(pathinfo($image['MediaUrl'], PATHINFO_EXTENSION) == $extension) {
# update values
$urls[] = $image['MediaUrl'];
}
}
}
print_r($urls);
這將找到相匹配的「監視」字符串,然後你只是過濾它們在PHP中的圖像。