GPX Upload Client

From OpenStreetMap Wiki
Jump to navigation Jump to search

broom

This article or section may contain out-of-date information. The information may no longer be correct, or may no longer have relevance.
If you know about the current state of affairs, please help keep everyone informed by updating this information. (Discussion)

Took a bit of trial and error with the cURL options to write a GPX upload client using PHP/cURL, but anyway, this does work:

<?php

$url = "http://www.openstreetmap.org/api/0.5/gpx/create";
$username="nick@hogweed.org";
$password="password";
$ch=curl_init ($url);
$formvars = array
    ("file"=>"@041107.gpx",
        "description"=>"Henley to Chithurst via Older Hill and Stedham",
        "tags"=>"West_Sussex footpaths",
        "public"=>1);

curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt ($ch, CURLOPT_HTTPHEADER,array("Expect:"));
curl_setopt ($ch,CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch,CURLOPT_POST,1 );
curl_setopt($ch,CURLOPT_POSTFIELDS,$formvars);
$resp=curl_exec($ch);
$httpCode=curl_getinfo($ch,CURLINFO_HTTP_CODE);

echo "Response: $resp, HTTP code: $httpCode";

?>