API: geocode

<?php
header('Access-Control-Allow-Origin: *');
$key = $_REQUEST['key'];	// Replace with $key = YOUR_API_KEY


$latlng = $_REQUEST['latlng'];
$address = $_REQUEST['address'];

if($key>'' && ($latlng>'' || $address>''))
{
	$url="https://maps.googleapis.com/maps/api/geocode/json?key=$key";

	if($latlng>'') { $url .= "&latlng=$latlng"; } 
	else $url .= "&address=" . urlencode($address);

	$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);

	$out = curl_exec($ch);

	curl_close($ch);

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