After a few requests, I’m creating a new version my SOTALogger App to work on Android Tablets using Spotlite instead of SMS. When I send comments from the app to the spotlite page, any spaces in the comments field are replaced by “%20”. Is there any way to have the spotlite page turn these back into spaces before sending the spot to SOTAWatch?
I suppose the alternative would be to have my app replace all spaces with some other character that Spotlite would pass unchanged.
Try URL encoding the string before POSTing to Spotlite. Works for me.
Here’s a link on URL Encoding in case you’re not familiar with the concept.
Proper http/url libraries should have a function to do this for you. In my case I use Python so I just pass any data into urllib.urlencode() and it returns a nice clean and compliant string to POST.
I don’t know if it is a limitation of the spotlite application that it cannot replace the url “%20” back to a space in the comments field, or if there is some other way to get it to insert a space.
The other options that I have thought of are having the user re-insert the comments or edit the spaces before posting (not optimal) or…
If you are using POST to send the data to Spotlite then the behaviour you are seeing is correct. Your App is doing it correctly.
It would appear that Spotlite is not treating the data correctly, i.e. it’s not un-urlencoding it. Contact the author of Spotlite and tell him about the problem.
Maybe I’m not understanding your solution. Whether I send the data to Spotlite with spaces, or with the url encoding, the result is the same; see my previous post.
Try copying and pasting both url’s into your internet browser to see what I mean. If you hit the post button with the “%20” in the comments field, they are passed to the spot as if you typed them in there.
Here is the test spot from the SOTAWatch page:
Thu 01:01 W5SMD/P on W5O/OU-013 - [edit] 146.00 cw
*Testing%20SOTA%20Logger.%20Not%20a%20real%20spot. (Posted by W5SMD)
The only other thing that I could think of with regards to the solution you presented is that there is a different url for directly posting a spot to spotlite without using the input screen. Is that the case?
I’ve recently been working with a python mail forwarding bridge to sotalite using python.
I used Firebug to observer how a normal POST from sotalite works. The following urllib2.request(url,data) works and does the right thing in sotalite. Your lanquage may vary:
url = “http://sota.plato.cybus.co.uk/Spotlite/postSpot”
data = “actCallsign=urcall&assoc=w7w&summit=999&freq=14.092&mode=cw&comments=TEST%20from%20FINDMESPOT%20Sat%20Msg&callsign=urcall&password=urpwd&submit=SPOT%21”
My rawdata looked like this:
rawdata = “actCallsign=urcall&assoc=w7w&summit=999&freq=14.092&mode=cw&comments=TEST from FINDMESPOT Sat Msg&callsign=urcall&password=urpwd&submit=SPOT!”
I created my data by using urllib.encode:
data = urllib.encode(rawdata,“=&”)
encode will ignore converting the = and & but convert any other encodeable character.
I would recommend you use “www.sota.org.uk” rather than “sota.plato.cybus.co.uk” as the latter could change at any time but the former is cast in concrete.