2016-09-12 4 views
1

: 나는 브라우저에 복사 할 때 XML의 응답을 반환Nominatim 응용 프로그램 오류가 나는 등의 지오 코딩에 대한 URL 요청을 보냅니다 PHP 응용 프로그램이 PHP

http://nominatim.openstreetmap.org/reverse?format=xml&lat=33&lon=34&addressdetails=1 

합니다. PHP 파일에서 전송하는 동일한 URL이 같은 응답이있을 때 :

<html><head><title>Bandwidth limit exceeded</title></head><body><h1>Bandwidth limit exceeded</h1><p>You have been temporarily blocked because you have been overusing OSM's geocoding service or because you have not provided sufficient identification of your application. This block will be automatically lifted after a while. Please take the time and adapt your scripts to reduce the number of requests and make sure that you send a valid UserAgent or Referer.</p><p>For more information, consult the <a href="http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy">usage policy</a> for the OSM Nominatim server.</body></head> 

그런 요청이 1 초 분에 위배되지 않고 5 분 간격으로 전송된다. 요청 제한. 어떻게 그 오류 메시지를 피할 수 있습니까?

// Send to nomintaim server reverse geocoding request 
    $url = "http://nominatim.openstreetmap.org/reverse?format=xml&lat=" . $loc['lat'] . "&lon=" . $loc['lng']. "&addressdetails=1"; 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); 
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); 
    $result = curl_exec($ch); 
    curl_close($ch); 
+0

을, 당신은 – cske

+0

를 사용하는 PHP 코드를 추가하십시오 나는 주요 질문 – Vitali

+0

AFAIK에 코드를 추가 컬이 UserAgent 또는 Referer 헤더를 설정하지 않을 것입니다. "당신은 당신의 어플리케이션에 대한 충분한 식별 정보를 제공하지 못했습니다."API에 대해 자신을 식별 할 수있는 코드가 있습니까? – cske

답변

0

당신은 & CURLOPT_REFERER 같은 CURLOPT_USERAGENT을 사용한다 : "당신이 유효한 해당 UserAgent 또는 리퍼러를 보내"

$userAgent = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2'; 
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); 
curl_setopt($ch, CURLOPT_REFERER, 'http://www.example.com/1');