PHP地理编码正在使用localhost但不在服务器上

时间:2014-08-21 21:25:32

标签: php google-maps localhost geocoding

是的,我把这一切都很好地工作,直到我把所有东西都转移到我的托管上,现在这不起作用

这段代码有什么问题,我需要在托管上配置一些东西吗?

这是php,它使用google maps api

function getlatlang($location)  
 {  
      $geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address='. urlencode($location) .'&sensor=false');  

      $output= json_decode($geocode);  

      return $output->results[0]->geometry->location;  
 }  

 $objlocation = getlatlang($postcode);  
 $latitude = $objlocation->lat;  
 $longitude = $objlocation->lng; 

我还打开了错误报告E_ALL,但没有显示任何内容,所以我尝试了-1并且它给出了以下错误。但我在localhost

上从未遇到过这些错误
Notice: Undefined offset: 0 in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 14

Notice: Trying to get property of non-object in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 14

Notice: Trying to get property of non-object in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 14

Notice: Trying to get property of non-object in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 18

Notice: Trying to get property of non-object in /websites/123reg/LinuxPackage22/fa/gs/an/fagsandbooze.com/public_html/test.php on line 19

2 个答案:

答案 0 :(得分:0)

始终检查localhost和主机上的php版本是否相同。 Geocoder仅适用于php> = 7.1 https://github.com/geocoder-php/GeocoderLaravel

答案 1 :(得分:-1)

事实证明我超出了我的日常要求。哎呀!

object(stdClass)#1 (3) { ["error_message"]=> string(56) "You have exceeded your daily request quota for this API." ["results"]=> array(0) { } ["status"]=> string(16) "OVER_QUERY_LIMIT" }