Currently I am using the following code:
$zipcode = '91762';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=restauraunts+".$zipcode."&rsz=large");
curl_setopt($ch, CURLOPT_HEADER, 0);
ob_start();
curl_exec($ch);
$data = ob_get_contents();
ob_end_clean();
curl_close($ch);
$restauraunts_array = json_decode($data, true);
foreach($restauraunts_array['responseData']['results'] as $key => $value) {
$results[] = array(
'title' => $value['titleNoFormatting'],
'address' => $value['streetAddress'],
'city' => $value['city'],
'state' => $value['region'],
'zipcode' => $zipcode,
'phone' => $value['phoneNumbers'][0]['number'],
'lat' => $value['lat'],
'lng' => $value['lng']
);
}
But it will only return 7 results. I am looking for a way to get back many more. I have looked through the API code and have not found any methods to get more results back. Can it be done? Can you point me to the documentation / implementation of how to get more than a few results?
ANSWER: Mikey was able to provide the answer I was looking for. Here is what I am doing to get 32 results:
$zipcode = '91762';
$results = array()
$counter = array(0,8,16,24);
foreach($counter as $page) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=restauraunts+".$zipcode."&rsz=large&start=".$page);
curl_setopt($ch, CURLOPT_HEADER, 0);
ob_start();
curl_exec($ch);
$data = ob_get_contents();
ob_end_clean();
curl_close($ch);
$restauraunts_array = json_decode($data, true);
if(!empty($restauraunts_array['responseData']['results'])) {
foreach($restauraunts_array['responseData']['results'] as $key => $value) {
$results[] = array(
'title' => $value['titleNoFormatting'],
'address' => $value['streetAddress'],
'city' => $value['city'],
'state' => $value['region'],
'zipcode' => $zipcode,
'phone' => $value['phoneNumbers'][0]['number'],
'lat' => $value['lat'],
'lng' => $value['lng']
);
}
}
return $results;