在php的两个地方之间的驾驶距离是行不通的

时间:2016-12-01 08:38:53

标签: php google-maps-api-3

我使用下面给出的代码来获取一个地方的纬度和经度来计算两个地方之间的行车距离。

function get_coordinates($city, $street, $province)
{
$address = urlencode($city.','.$street.','.$province);
$url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false&region=Poland";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
$status = $response_a->status;
if ( $status == 'ZERO_RESULTS' )
{
    return FALSE;
}
else
{
    $return = array('lat' => $response_a->results[0]->geometry->location->lat, 'long' => $long = $response_a->results[0]->geometry->location->lng);
   return $return;
}

}

我不明白。它显示一个空数组。当echo $ status我得到了'OVER_QUERY_LIMIT'。 此代码在godaddy服务器中完美运行。当我将其更改为网络解决方案服务器时,我收到了这些错误。 怎么解决这个问题?

由于

1 个答案:

答案 0 :(得分:0)

错误OVER_QUERY_LIMIT表示您当天已经用尽了API。

以下是解释:

  

每天2,500个免费请求,以客户端和服务器端查询的总和计算。

     

每秒50个请求,以客户端和服务器端查询的总和计算。

Google Usage Limits

您可以根据需要生成少量API密钥,并在用尽时切换它们。

Generate API Key from Google Console

希望这有帮助!