Google의 간단한 XML을 사용하여 주소 문자열을 경도와 위도로 변환하는 간단한 함수가 있습니다. 나는 가끔 이상한 경고 오류 :simplexml_load_file 경고 오류
은 경고 : simplexml_load_file (http://maps.googleapis.com/maps/api/geocode/xml?address=&sensor=true) : HTTP 요청이 실패 이 스트림을 열지 못했습니다! HTTP/라인 /search_results.php 1.0 500 내부 서버 오류 193
경고 : simplexml_load_file() : I/O 경고 : 라인 193에 /search_results.php 외부 실체 "http://maps.googleapis.com/maps/api/geocode/xml?address=&sensor=true" 을로드하지 못했습니다 로드하지 않는 URL
이 오류를 방지하려면 더 좋은 방법이 있습니까?
내 코드는 다음과 같습니다 : 당신이 빈 주소를 지오 코딩하려는 것처럼
$geo_address = urlencode($address);
$request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$geo_address."&sensor=true";
$xml = simplexml_load_file($request_url) or die ("url not loading");
$status = $xml->status;
if ($status=="OK") {
$lat = $xml->result->geometry->location->lat;
$lon = $xml->result->geometry->location->lng;
}
내부 PHP 파일'(search_results.php)'에 'HTTP/1.0 500 내부 서버 오류'문제가있는 것 같아서 [[this] try (http://stackoverflow.com/questions/10524748/php) -file-get-contents-500-internal-server-error) 아웃 – bjiang