Spaces in Spotlite Comments

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.

Thanks,
Stephen

In reply to W5SMD:

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.

Andy
MM0FMF

In reply to MM0FMF:
The problem isn’t sending it to Spotlite, it’s the encoding when it gets there.

For example if I send:
Summits on the Air world/

The comments section has:
hello%20world

Same thing if I send:
http://www.sota.org.uk/Spotlite/spot/comments/hello%20world/

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…

Replacing.the.spaces.with.periods.to.make.it.more.readable.

or_maybe_underscores_would_work

Any thoughts?

In reply to W5SMD:

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.

Colin G8TMV

In reply to W5SMD:

Well having posted a solution that works, I’ll leave you to decide whether to solve your issue the hard way or easy way!

HINT: Read the paged linked in my reply, especially the answer to your problem.

Andy
MM0FMF

In reply to MM0FMF:

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?

In reply to W5SMD:

Line 11 on the page linked:

“URLs cannot contain spaces. URL encoding normally replaces a space
with a + sign.”

Andy
MM0FMF

In reply to MM0FMF:

Here’s the code from the SMS bot:

if spot == True:
    headers = {"Content-type": 

“application/x-www-form-urlencoded”,
“Accept”:
“text/plain”}
#
# log the details of the spot but not the account
#
partial_spotdata = urllib.urlencode( param )
print 'Posting a spot with: '
print partial_spotdata
smslog.log(partial_spotdata)
#
# password account stuff goes here
#
param ‘callsign’ ] = …
param ‘password’ ] = …
param ‘submit’ ] = 'SPOT!'
spotdata = urllib.urlencode( param )

    retval = 200
    try:
        conn = httplib.HTTPConnection("www.sota.org.uk:80")
        conn.request("POST", "/Spotlite/postSpot", spotdata, headers)
        response = conn.getresponse()
        data = response.read()
        conn.close()
        smslog.log( 'SPOTLITE: '+str(response.status) + '\n' + data)
        retval = response.status
    except IOError:
        print 'HTTP IOError exception with www.sota.org.uk:80\n'
        smslog.log( 'SPOTLITE: IOError, spot deleted')

EDIT: lost the formatting :frowning:

Andy
MM0FMF

In reply to W5SMD:

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.

Hope this helps!

In reply to NX1P:

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.

Andy
MM0FMF

In reply to MM0FMF:
Thanks Andy, I’ve made the change in my code.