php - How to get google api 10 search result -


how can 10 search result google api, have code showing 4 search results only

$query = 'akon'; $url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=".$query;  $body = file_get_contents($url); $json = json_decode($body);  for($x=0;$x<count($json->responsedata->results);$x++){ echo "<b>result ".($x+1)."</b>"; echo "<br>url: "; echo $json->responsedata->results[$x]->url; echo "<br>visibleurl: "; echo $json->responsedata->results[$x]->visibleurl; echo "<br>title: "; echo $json->responsedata->results[$x]->title; echo "<br>content: "; echo $json->responsedata->results[$x]->content; echo "<br><br>"; } 

the maximum number of results can obtained api 8. can adding "&rsz=large" url below.

$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&q=".$query;

to more 8 results, need perform above operation twice adding parameter called "start" 0 index based. first page of results $url must be,

$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&start=0&q=".$query;

for second page be,

$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&start=8&q=".$query;


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -