Editing via a PHP script

I’m trying to change an existing node using a PHP script. My simple test script (which will, if it works, add the “addr:street” key) is as follows:

$data = "<?xml version='1.0' encoding='UTF-8'?>\n";
$data .= "<osm version='0.6' generator='avantman42-php'>\n";
$data .= "<changeset>\n";
$data .= "<node id='408368412' lat='48.13213250462367' lon='11.543279671866909'>\n";
$data .= "<tag k='name' v='Kebab Range'/>\n";
$data .= "<tag k='amenity' v='fast_food'/>\n";
$data .= "<tag k='cuisine' v='kebab'/>\n";
$data .= "<tag k='addr:street' v='Ford Green Road'/>\n";
$data .= "</node>\n";
$data .= "</changeset>\n";
$data .= "</osm>\n";

$url = "http://www.openstreetmap.org/api/0.6/node/408368412";
$r = http_put_data ($url, $data, array ("httpauth"=>"user:password"));
print_r ($r);

It returns the following:

Can anyone tell me what I’m doing wrong? I suspect the XML is wrong, but I can’t work out what is wrong with it.


The XML code you send to the server does not contain a version number, as specified in the API. I’m not sure whether that’s the only error source…

IMHO the OSM server should output a different error code (4xx) in such situations - it looks like a server problem when generating this error code…

I found the API page you linked to just as you posted your reply. I had been using the HTTP_Protocol_Specification page as a reference, and changing mention of 0.3 or 0.4 to 0.6 :roll_eyes:

I think I might be able to get somewhere now. Thanks.