2016-09-12 3 views
1

ich PHP-Anwendung haben, die für die Geokodierung als URL-Anfrage sendet:Nominatim Anwendungsfehler PHP

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

, wenn ich in Browser kopieren kehrt XML reagieren. Wenn gleiche URL von PHP-Datei zu senden hat Antwort als:

<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> 

dass Anforderung alle 5 Minuten sendet, die nicht mehr als 1 sec min verletzt. Anfrage Einschränkung. Wie kann vermieden werden, diese Fehlermeldung zu haben?

// 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

"dass Sie einen gültigen Useragent oder Referer senden", fügen Sie bitte die PHP-Code, den Sie – cske

+0

verwenden habe ich den Code Hauptfrage – Vitali

+0

AFAIK curl richtet keinen UserAgent- oder Referer-Header für Sie ein, der von Ihnen eingefügt werden soll. "Sie haben Ihre Anwendung nicht ausreichend identifiziert." Haben Sie einen Code, um sich für api zu identifizieren? – cske

Antwort

0

Sie sollten CURLOPT_USERAGENT & CURLOPT_REFERER wie folgt verwenden:

$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');