0

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.

4

1 回答 1

1

问题是当我有一个带代理的服务器时。[...] 我收到“OVER_QUERY_LIMIT”错误。

听起来很多其他人都在使用代理,其中一个已经超过了(每天约 1000 个?)查询限制。

于 2011-04-05T20:44:09.037 回答