PHP地理编码在localhost上运行,但在服务器上不运行

问题描述 投票:-2回答:2

对,我一切顺利,直到我将所有内容转移到主机上,而现在却无法正常工作

此代码有什么问题,我需要在主机上配置一些东西吗?

这里是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,它给出了以下错误。但是我在本地主机上却从未遇到这些错误

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
php google-maps localhost geocoding
2个回答
0
投票

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


-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" } 
© www.soinside.com 2019 - 2024. All rights reserved.