i am using PHP - Curl to Upload GPX traces.
$fields_file = '2004062.gpx';
$fields_description = 'Sample Description';
$fields_tags = 'public';
$fields_visibility = 'public';
$FF['file'] = $fields_file;
$FF['description'] = $fields_description;
$FF['tags'] = $fields_tags;
$FF['visibility'] = $fields_visibility;
http_build_query($FF);
$OSMuser = 'csrm.xxxxxxx@gmail.com';
$OSMpass = 'xxxxxxx*';
$host = 'http://api.openstreetmap.org/api/0.6/gpx/create';
$agent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$process = curl_init($host);
curl_setopt($process, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_USERPWD, $OSMuser . ":" . $OSMpass);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
curl_setopt($process, CURLOPT_POSTFIELDS, http_build_query($FF));
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($process, CURLOPT_USERAGENT, $agent);
$return = curl_exec($process);
curl_close($process);
Response:
string(472) "HTTP/1.1 400 Bad Request
Date: Thu, 30 Jul 2015 06:29:14 GMT
Server: Apache/2.4.7 (Ubuntu)
Cache-Control: no-cache
Vary: Accept-Language,Origin
X-XSS-Protection: 1; mode=block
Content-Language: en
X-Request-Id: VbnEOn8AAQEAAG2TtpMAAAAZ
X-Runtime: 0.012558
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-Powered-By: Phusion Passenger 5.0.14
Status: 400 Bad Request
Content-Length: 0
Connection: close
Content-Type: text/html; charset=utf-8
asked
30 Jul '15, 08:20
CSRM Kozhikode
11●1●1●2
accept rate:
0%
I don't know the reason for the 400 status code but you should not send a wrong user agent.