geocode with proxy php


geocode with proxy php

我是新来的,我正在使用地图api来地理编码地址。在我的机器上我没有任何问题。问题是当我有一个代理服务器。我尝试使用两个不同的函数来配置代理:

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;
}

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;
}

然后我用这些行调用这个函数:

            $address = urlencode($address);
            $data = $this->curl("http://maps.google.com/maps/api/geocode/xml?address={$address}&sensor=false");
            $lat_lng = simplexml_load_string($data);

但是我得到'OVER_QUERY_LIMIT'错误。

你知道吗?谢谢。

问题是当我有一个代理服务器。[…我得到"OVER_QUERY_LIMIT"错误。

听起来这个代理被很多人使用,其中一个已经超过了(~1000-a-day?)查询限制