duanfu1942 2014-08-28 05:46 采纳率: 100%
浏览 442

如何从Bing搜索API获得超过50个结果?

I have used the code below with the Bing image API to search images. But the code gets only 50 results. How can I get more results?

$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>";
  • 写回答

1条回答 默认 最新

  • duanchen7703 2016-09-26 20:11
    关注

    You should append your request with $top=50&$skip=0 to get the first 50 results and with $top=50&$skip=51 to get the next 50 results, it's better to create API key to get the second request as Bing permits 1 transaction per second and you may get this message error if you exceeded the limits: "503 The number of requests per minute for the subscription has reached the maximum threshold that is allowed."

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号