The following is a little OSM Overpass API example with PHP SimpleXML
This following lines shows how i try to query an Overpass Endpoint with standard PHP.
//
// 1.) Query an OSM Overpass API Endpoint
//
$query = 'node ["amenity"~".*"]
(38.415938460513274,16.06338500976562,39.52205163048525,17.51220703125);
out;';
$context = stream_context_create(['http' => [
'method' => 'POST',
'header' => ['Content-Type: application/x-www-form-urlencoded'],
'content' => 'data=' . urlencode($query),
]]);
# please do not stress this service, this example is for demonstration purposes only.
$endpoint = 'http://overpass-api.de/api/interpreter';
libxml_set_streams_context($context);
$start = microtime(true);
$result = simplexml_load_file($endpoint);
printf("Query returned %2\$d node(s) and took %1\$.5f seconds.\n\n", microtime(true) - $start, count($result->node));
i get back the following errors.
Warning: simplexml_load_file(): php_network_getaddresses: getaddrinfo failed: System error in /in/2HOpS on line 17 Warning: simplexml_load_file(http://overpass-api.de/api/interpreter): failed to open stream: php_network_getaddresses:
what goes wrong here?