2011-11-01 38 views
0

这是我的代码。对10条记录可以正常工作。但是当我增加数字时它会提示错误。请检查它并让我知道你是否有任何解决方案。我无法通过谷歌搜索API获得50条结果记录

Thanks in advance, 
    Ravi Sharma 
    Softobiz Technologies 
<?php 

    # JSON SEARCH RESULT 

    // This example request includes an optional API key which you will need to 
    // remove or replace with your own key. 
    // Read more about why it's useful to have an API key. 
    // The request also includes the userip parameter which provides the end 
    // user's IP address. Doing so will help distinguish this legitimate 
    // server-side traffic from traffic which doesn't come from an end-user. 

    $url = 'https://www.googleapis.com/customsearch/v1?key=AIzaSyC4o52-Q90FxNzMxY9FNryrONierFS3la8&cx=016278085151347603490%3Affuoqez1cew&q=ravi&num=20'; 
    // sendRequest 
    // note how referer is set manually 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_REFERER, '202.164.43.51'); 
    $body = curl_exec($ch); 
    curl_close($ch); 

    // now, process the JSON string 
    $array = json_decode($body); 
    // now have some fun with the results... 

    echo "<pre>"; 
    print_r($array); 

    ?> 
+0

**你什么错误**? – SLaks

回答

0
从文档

另外:

Pagination 
This API can return the first 100 search results, in chunks (pages) up to 10 search results long. You can specify the page of search results to return using the start and num query parameters. 
+0

谢谢阿什利它的帮助 –

0

http://code.google.com/apis/websearch/

注:谷歌网络搜索API已正式弃用2010年11月1日将继续按照我们的弃用政策工作,但请求的数量,您可能会使每一天会受到限制。因此,我们鼓励您转移到新的自定义搜索API。

来源:http://code.google.com/apis/soapsearch/api_faq.html#tech8

8.是否有我可以每次查询收到成效的数量限制吗?

是的。 您可以检索每个查询最多10个结果,并且您无法访问任何给定查询的第1000个结果以外的信息。

你遇到的是单一的请求结果限制。