Different nominatim XML response using FireFox vs cURL and php

Hi forum members.

I am struggling with a weird case of different responses when looking at the XML returned from openstreetmaps API in FireFox versus requesting the same resource using cURL and PHP.

CASE:

Try opening the URL in e.g. FireFox address bar:

http://nominatim.openstreetmap.org/search?format=xml&polygon=0&q=Albrechtice&countrycodes=CZ

You will see that “place” node number 4 (out of 9) from the top is looking like this:

Pay close attention to the place_id, osm_id, latitude/longitude and boundingbox information.

Now; try requesting the same url programmatically:

<?php $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, "[http://nominatim.openstreetmap.org/search?format=xml&polygon=0&q=Albrechtice&countrycodes=CZ](http://nominatim.openstreetmap.org/search?format=xml&polygon=0&q=Albrechtice&countrycodes=CZ)" ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_TIMEOUT, 40 ); $result = curl_exec( $ch ); $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $doc->loadXML( $result ); $doc->save( "external_xml_saved.xml" ); ?>

Open the saved XML file. Place “node” number 4 (out of 9) now has totally different OSM data:

Can someone please explain to me why there is a difference?

Many thanks for helping out,

Kevin

It might depend on what language your browser is set to? ie what accept headers it is sending.

Firebug reported the following when requesting the nominatim URL in question:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: en-us,en;q=0.5
Connection: keep-alive
Host: nominatim.openstreetmap.org
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1