Google-api-php-client CsutomSearch获得下一个结果

时间:2016-09-20 21:37:18

标签: php google-api-php-client google-custom-search

我已实施自定义搜索,并尝试获取下一页结果:

<?php
require __DIR__ . '/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName("AAAAAAAAAA");
$client->setDeveloperKey("xxxxxxxxxxxxxxxx");
$service = new Google_Service_Customsearch($client);
//Do the query
$query = 'a';
$optParams = array(
        'num' => 10,
        'cx' => 'cxcxcxcxcxcxcxcxcxcxcxcx'
        );
$results = $service->cse->listCse($query, $optParams);
print_r($results);  

如何获得下一组结果?文档说应该使用num和start,即&amp; num = 10&amp; start = 21 但我总是得到0结果。更糟糕的是:更改启动参数会更改结果的数量:

  • num = 10&amp; start = 0 =&gt; 15100总结果,
  • num = 10&amp; start = 11 =&gt; 7540总结果
  • num = 10&amp; start = 31 =&gt; 0 totalResults

生成的URI给出(当然,我使用正确的key参数运行查询): https://www.googleapis.com/customsearch/v1?q=a&cx=009948471157722620218%3Aqb_f79-w5zg

我在做什么/在哪里出错?任何帮助将不胜感激!

0 个答案:

没有答案