I'm new and I'm using maps api to geocode address. In my machine I don't have any problem. The problem is when I have a server with proxy. I tried to configure the proxy using two different functions:
function curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXY, "http://my_proxy");
curl_setopt($ch, CURLOPT_PROXYPORT, my_port);
curl_setopt($ch, CURLOPT_HEADER,0); //Change this to a 1 to return headers
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
var_dump($data);
curl_close($ch);
return $data;
}
or
function curl($url)
{
$opts = array('http' => array('proxy' => 'tcp://my_proxy', 'request_fulluri' => true));
$context = stream_context_create($opts);
$data = file_get_contents($url, false, $context);
return $data;
}
and then I'm calling that function using these lines:
$address = urlencode($address);
$data = $this->curl("http://maps.google.com/maps/api/geocode/xml?address={$address}&sensor=false");
$lat_lng = simplexml_load_string($data);
but I'm getting 'OVER_QUERY_LIMIT' error.
Do you have any idea? Thanks.