我使用Bing图像API下面的代码来搜索图片。但代码只获得50个结果。我怎样才能获得更多结果?
$acctKey = 'Account key here';
$rootUri = 'https://api.datamarket.azure.com/Bing/Search';
$query = 'Kitchen';
$serviceOp = 'Image';
$market ='en-us';
$query = urlencode("'$query'");
$market = urlencode("'$market'");
$requestUri = "$rootUri/$serviceOp?\$format=json&Query=$query&Market=$market";
$auth = base64_encode("$acctKey:$acctKey");
$data = array(
'http' => array(
'request_fulluri' => true,
'ignore_errors' => true,
'header' => "Authorization: Basic $auth"
)
);
$context = stream_context_create($data);
$response = file_get_contents($requestUri, 0, $context);
$response=json_decode($response);
echo "<pre>";
print_r($response);
echo "</pre>";
答案 0 :(得分:0)
您应该使用$ top = 50&amp; $ skip = 0附加您的请求以获得前50个结果并使用$ top = 50&amp; $ skip = 51来获得接下来的50个结果,最好创建API密钥以获取Bing的第二个请求允许每秒1个事务,如果超出限制,您可能会收到此消息错误:“503数字 订阅的每分钟请求数已达到允许的最大阈值。“