Welcome Guest Search | Active Topics
Track Upload API Options · View
andread
Posted: 29 Jan 10


Posts: 5
Location: Greece
Can you give some info on the API that we can use to upload GPX tracks on runsaturday?

thank you
Manolis

Hollywoof
Posted: 29 Jan 10


Posts: 4,379
Location: United Kingdom
Hi andread

Those are some great looking sites you have there for flying:
- http://www.leonardoxc.net/
- http://livetrack24.com/

Sorry the runsat upload API isn't very well documented at the moment - we just keep on growing too fast BigGrin

There are 4 upload APIs already available:
- A SOAP service for GPX format data - this is used by iSportTracks currently - I think this is probably best for you?
- A SOAP service for Garmin TCX format data - this is used by SportTracks2 plugin
- A SOAP service for custom binary (Navmi) format data - this is used by Navmi currently
- An email service for GPX format data - this is used by Google MyTracks currently

For the first of these, uploading GPX, the SOAP API is at http://www.runsaturday.com/runsaturday/GPXSync.asmx?op=UploadUsingPasswordFrom

The parameters are:

sportType - which can be any of
"Run"
"Swim"
"Bike"
"Walk"
"Water"
"Winter"
"Skate"
"Cross"
(don't send the quotation marks - just the inner string)

sportSubType - this is free text - but you should try (if possible) to use one of the subtypes on the site (for a list of all subtypes try the dropdown on http://www.runsaturday.com/Train/Add/Direct

compressedData - this is GPX 1.0 or GPX 1.1 GZip'd and then base 64 encoded... I can put some test strings somewhere if that helps.

collectedFrom - this identifies the collection device - you might want to set this to your website name - or (if you know it) to something like the original GPS data device/phone.

I hope that helps :)

There are also lots of APIs to get data out of runsaturday - see http://www.runsaturday.com/About_Us/Developers

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
Hollywoof
Posted: 29 Jan 10


Posts: 4,379
Location: United Kingdom
And of course...

The username and password need to go into the SOAP header:
<soap:Header>
<UploadTrackCredentials xmlns="http://www.runsaturday.com">
<UserName>username here</UserName>
<SecretKey>password here</SecretKey>
</UploadTrackCredentials>
</soap:Header>

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
andread
Posted: 29 Jan 10


Posts: 5
Location: Greece
Great!,
Thats all the info i need for a start!
andread
Posted: 29 Jan 10


Posts: 5
Location: Greece
OK got it, here is a basic test upload

(you need the nusoap library for php)

Code:

require_once("lib/soap/nusoap.php");
    $wsdlURL = "http://www.runsaturday.com/runsaturday/GPXSync.asmx";
    $soap = new nusoap_client($wsdlURL);
    // $soap->setDebugLevel(9);
    
    $username="yourusername";
    $pass="yourpass";

$header="<UploadTrackCredentials xmlns=\"http://www.runsaturday.com\">
      <UserName>$username</UserName>
      <SecretKey>$pass</SecretKey>
    </UploadTrackCredentials>";
 
    
    $parameters['sportType'] ="Run";
    $parameters['sportSubType'] ="Trail Running";
        
    // now get the gpx file
    $data=file_get_contents("1.gpx");
    echo "original file length: ".strlen($data)."<br>";
    $data=gzencode($data);
    echo "gzipped file length: ".strlen($data)."<br>";
    $data=base64_encode($data);
    echo "base64 file length: ".strlen($data)."<br>";
    
    $parameters['compressedData'] =$data;
    $parameters['collectedFrom'] ="LiveTrack24";
    
    $result = $soap->call('UploadUsingPasswordFrom', $parameters, "http://www.runsaturday.com","http://www.runsaturday.com/UploadUsingPasswordFrom", $header,    null,"rpc","literal" );
    
    if ($debug) {    
        print_r($result);        
        // Display the request and response
        echo '<h2>Request</h2>';
        echo '<pre>' . $soap->request. '</pre>';
        echo '<h2>Response</h2>';
        echo '<pre>' .$soap->response . '</pre>';
    }

andread
Posted: 01 Feb 10


Posts: 5
Location: Greece
I have just activated the posting of live tracks via livetrack24.com to RunSaturday.com
BarryCornelius
Posted: 01 Aug 10


Posts: 1
Location: United Kingdom
andread wrote:
OK got it, here is a basic test upload
...


Thanks very much for posting that code.

I tried it with a gpx file but it didn't work. It seems to be failing at the decompression.
Code:

original file length: 140392<br>gzipped file length: 23481<br>base64 file length: 31308<br>

Array
(
    [faultcode] => soap:Server
    [faultstring] => System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: InString
   at System.Convert.FromBase64String(String s)
   at SlodgeRoutesTools.Utils.Compression.Decompress(String compressedText, Boolean hasHeader) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\Utils\Compression.cs:line 68
   at SlodgeRoutesTools.Utils.Compression.DecompressNoHeader(String compressedText) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\Utils\Compression.cs:line 96
   at SlodgeRoutesTools.GPXTrackUpload.DoUpload(UploadTrackCredentials credentials, String sportTypeAsString, String sportSubType, String compressedData, Boolean skipDuplicates, Boolean useSecretKeyNotPassword, String collectedFrom) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\GPXTrackUpload.cs:line 130
   at GPXSync.UploadUsingPasswordFrom(String sportType, String sportSubType, String compressedData, String collectedFrom)
   --- End of inner exception stack trace ---
    [detail] =>
)
<h2>Request</h2><pre>POST /runsaturday/GPXSync.asmx HTTP/1.0
Host: www.runsaturday.com
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "http://www.runsaturday.com/UploadUsingPasswordFrom"
Content-Length: 32094

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><UploadTrackCredentials xmlns="http://www.runsaturday.com">
      <UserName>BarryCornelius</UserName>
      <SecretKey>somepasswordwhichI'veremoved</SecretKey>
    </UploadTrackCredentials></SOAP-ENV:Header><SOAP-ENV:Body><ns1912:UploadUsingPasswordFrom xmlns:ns1912="http://www.runsaturday.com"><sportType>Run</sportType><sportSubType>Trail Running</sportSubType><compressedData>H4sIAAAAAAAAA629y7Jlx5UkNq+vgGHO...</compressedData><collectedFrom>MyGarmin305</collectedFrom></ns1912:UploadUsingPasswordFrom></SOAP-ENV:Body></SOAP-ENV:Envelope></pre><h2>Response</h2><pre>HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.0
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Sun, 01 Aug 2010 09:59:57 GMT
Connection: close
Content-Length: 1466

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.ArgumentNullException: Value cannot be null.
Parameter name: InString
   at System.Convert.FromBase64String(String s)
   at SlodgeRoutesTools.Utils.Compression.Decompress(String compressedText, Boolean hasHeader) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\Utils\Compression.cs:line 68
   at SlodgeRoutesTools.Utils.Compression.DecompressNoHeader(String compressedText) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\Utils\Compression.cs:line 96
   at SlodgeRoutesTools.GPXTrackUpload.DoUpload(UploadTrackCredentials credentials, String sportTypeAsString, String sportSubType, String compressedData, Boolean skipDuplicates, Boolean useSecretKeyNotPassword, String collectedFrom) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\GPXTrackUpload.cs:line 130
   at GPXSync.UploadUsingPasswordFrom(String sportType, String sportSubType, String compressedData, String collectedFrom)
   --- End of inner exception stack trace ---</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope></pre>


I looked at the web page at http://www.runsaturday.com/runsaturday/GPXSync.asmx?op=UploadUsingPasswordFrom.

I took the bit from andread's PHP script that generates the base64 gzipped of the GPX and put the base64 into a POST request using the curl command at a Linux command line.

I also filled in the form at the top of that web page.

Both of these last two attempts resulted in:
Code:

System.NullReferenceException: Object reference not set to an instance of an object.
   at SlodgeRoutesTools.BaseTrackUpload.UserFromDNNCredentials(UploadTrackCredentials credentials) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\GPXTrackUpload.cs:line 71
   at SlodgeRoutesTools.BaseTrackUpload.UserIdFromDNNCredentials(UploadTrackCredentials credentials) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\GPXTrackUpload.cs:line 65
   at SlodgeRoutesTools.GPXTrackUpload.DoUpload(UploadTrackCredentials credentials, String sportTypeAsString, String sportSubType, String compressedData, Boolean skipDuplicates, Boolean useSecretKeyNotPassword, String collectedFrom) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\GPXTrackUpload.cs:line 124
   at GPXSync.UploadUsingPasswordFrom(String sportType, String sportSubType, String compressedData, String collectedFrom)


The gpx file I'm using is:
http://www.northeastraces.com/runningstatic/records/2010-07-28a.gpx

I've uploaded the base64 gzipped of the GPX to:
http://www.northeastraces.com/runningstatic/records/2010-07-28a.encoded
Hollywoof
Posted: 02 Aug 10


Posts: 4,379
Location: United Kingdom
Hi Barry

Not sure why the sample code shouldn't work - it's the code andread has live.

On the second error - the Null exception - that suggests you've not got the username and password in the header correctly.

Hope that helps a bit

Stuart

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
nielsdenotter
Posted: 05 Aug 10


Posts: 5
Location: Netherlands
I have the same problem with the PHP code above. Would really like to have this working and change it to upload from a Linux script after reading the data from my FR305. Hope anyone understands what goes wrong?

The output I get is identical;

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.ArgumentNullException: Value cannot be null.
Parameter name: InString
at System.Convert.FromBase64String(String s)
at SlodgeRoutesTools.Utils.Compression.Decompress(String compressedText, Boolean hasHeader) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\Utils\Compression.cs:line 68
at SlodgeRoutesTools.Utils.Compression.DecompressNoHeader(String compressedText) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\Utils\Compression.cs:line 96
at SlodgeRoutesTools.GPXTrackUpload.DoUpload(UploadTrackCredentials credentials, String sportTypeAsString, String sportSubType, String compressedData, Boolean skipDuplicates, Boolean useSecretKeyNotPassword, String collectedFrom) in C:\Users\Stuart\Documents\Visual Studio 2010\Projects\DNN\SlodgeRoutesTools\GPXTrackUpload.cs:line 130
at GPXSync.UploadUsingPasswordFrom(String sportType, String sportSubType, String compressedData, String collectedFrom)
--- End of inner exception stack trace ---</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
Hollywoof
Posted: 06 Aug 10


Posts: 4,379
Location: United Kingdom
I'm running the decode code in C#

I've taken a quick look at http://www.northeastraces.com/runningstatic/records/2010-07-28a.encoded and it decodes fine inside the runsat libraries.

Looking at the stack trace it seems that the problem is that the System.Convert.FromBase64String routine is being passed a "null" - which suggests that the data is simply never making it into the right name on the webservice - perhaps some naming conflict...

There's something odd going on - maybe with the xml namespaces? I'll keep looking...

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
Hollywoof
Posted: 06 Aug 10


Posts: 4,379
Location: United Kingdom
OK.

I've used Fiddler2 to handcraft some requests based on the XML provided above

The problem seems to be in namespacing.

This section fails:

<ns1912:UploadUsingPasswordFrom xmlns:ns1912="http://www.runsaturday.com">
<sportType>Run</sportType>
<sportSubType>Trail Running</sportSubType>
<compressedData>H4sIAAAAAAAAA629y7Jlx5UkNq+vgGHO...</compressedData>
<collectedFrom>MyGarmin305</collectedFrom>
</ns1912:UploadUsingPasswordFrom>

This section succeeds:
<ns1912:UploadUsingPasswordFrom xmlns:ns1912="http://www.runsaturday.com">
<ns1912:sportType>Run</ns1912:sportType>
<ns1912:sportSubType>Trail Running</ns1912:sportSubType>
<ns1912:compressedData>H4sIAAAAAAAAA629y7Jlx5UkNq+vgGHO...</ns1912:compressedData>
<ns1912:collectedFrom>MyGarmin305</ns1912:collectedFrom>
</ns1912:UploadUsingPasswordFrom>


And this section succeeds too:

<UploadUsingPasswordFrom xmlns="http://www.runsaturday.com">
<sportType>Run</sportType>
<sportSubType>Trail Running</sportSubType>
<compressedData>H4sIAAAAAAAAA629y7Jlx5UkNq+vgGHO...</compressedData>
<collectedFrom>MyGarmin305</collectedFrom>
</UploadUsingPasswordFrom>

I'm not 100% sure what's going wrong here - is this a .Net bug or a PHP/NuSoap bug - I'm going to have to go find some xml references to find out... Also wil try googling to see if there are any easy solutions

Stuart

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
Hollywood
Posted: 06 Aug 10

Posts: 123
It seems like there's lots of posts out there about nusoap and headers and namespaces.

Not perfect... but one quick and dirty solution is that you could try creating the XML content yourself - like http://users.skynet.be/pascalbotte/rcx-ws-doc/nusoapadvanced.htm

Alternatively, maybe there's a nusoap or php versioning thing going on - as I know Andread's code works in some configurations!

If you like the site, please:
- add yourself as a fan to the facebook page
- rate the SportTracks plugin and recommend us on the SportTracks forum
- talk about us in real life, on your blogs and on any other forums you visit

Thanks - it all helps other people find the site :)
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net

Recent Photos

Recent PBs

Aonikenk 0:55:19
14km Road - 14km de Belvédère
drumball 4:08:13
45k - Great Ocean Road Real Estate Marathon
1bubobubo 0:27:32
6.2k - Žehrovický Kalspotkros
Monika 2:56:58
36k/18k - ŠUTR 54
index 0:24:53
6.1k - 1. LBP 2013 - Pisárky
Luky 3:29:11
Marathon - Volkswagen Maraton Praha
1bubobubo 3:23:26
Marathon - Prague Marathon 2013
runaway_chris 1:38:58
0.4k/22k/5k - 11. MRRC Stadt-Triathlon München

Recent Videos