API: nearbysearch

<?php
header('Access-Control-Allow-Origin: *');

$key = $_REQUEST['key'];	// Replace with $key = YOUR_API_KEY


$location = $_REQUEST['location'];
if($location=='') $location = "37.4220147,-122.0840693";	// defaults to Googleplex

$type = $_REQUEST['type'];
if($type=='') $type = "restaurant";

$rankby = $_REQUEST['rankby'];
if($rankby=='') $rankby = "distance";


if($key>'')
{
	$url="https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=$key";
	$url .= "&rankby=$rankby";
	$url .= "&location=$location";
	$url .= "&type=$type";

	$echo .=  $url;	$echo .=  "\n\n";
	$ch = curl_init($url); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

	$data = curl_exec($ch);
	curl_close($ch);

	$out = $data;

	header('Content-Type: application/json');
	echo $out;
}
?>