Php 命名应用程序错误

Php 命名应用程序错误,php,curl,openstreetmap,php-curl,nominatim,Php,Curl,Openstreetmap,Php Curl,Nominatim,我有一个PHP应用程序,它发送url请求进行地理编码,如下所示: http://nominatim.openstreetmap.org/reverse?format=xml&lat=33&lon=34&addressdetails=1 当我复制到浏览器时,返回XML响应。当从PHP文件发送相同url时,响应为: <html><head><title>Bandwidth limit exceeded</title></

我有一个PHP应用程序,它发送url请求进行地理编码,如下所示:

http://nominatim.openstreetmap.org/reverse?format=xml&lat=33&lon=34&addressdetails=1
当我复制到浏览器时,返回XML响应。当从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>

您应该像这样使用CURLOPT_USERAGENT和CURLOPT_REFERER:

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

“如果您发送了一个有效的UserAgent或Referer”,请添加您使用的php代码我将代码添加到主要问题Faik curl不会为您设置您应该包含的UserAgent或Referer标题,“您没有提供足够的应用程序标识”你有api的自我识别代码吗?你已经超过了带宽限制。请等待解锁,然后重试。阅读,或者使用。似乎必须使用
CURLOPT\u USERAGENT
来使用PHP cURL设置用户代理。
$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');