"secret" save of game scores

Q&A's, tips, howto's
Locked
jazper
Posts: 92
Joined: Thu Dec 10, 2009 8:26 am
Location: South Africa

"secret" save of game scores

Post by jazper »

I can't work out how to update and retrieve scores stored in a sqlite database on my web site. A game on an Android phone needs to do this. Is there some kind of "secret" way of doing this that bypasses the business of visibly logging on and clicking submit buttons? My site has a database on it, and is written in newLISP.

People do this all the time, so I expect it must be doable with cgi and newLISP. Any tips or pointers toward the approach will be much appreciated.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: "secret" save of game scores

Post by Lutz »

On the client side data could be sent using HTTP GET or POST requests. On the server side you would use CGI and cgi.lspt to extract the parameters:

http://www.newlisp.org/code/modules/cgi.lsp.html

and load sqlite3.ls in your CGI script to interface to the SQLite3 database on the server:

http://www.newlisp.org/code/modules/sqlite3.lsp.html

It is not clear to me if that game on your Android device is written by you, or if this is a purchased game. Then you would need to know the format data are sent out. If you are programming the Android device, you would need to program GET or POST requests yourself. Using newLISP that would be using either get-url or post-url.

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Re: "secret" save of game scores

Post by xytroxon »

To access a web page cgi interface programatically, use this cURL FORM technique...

Using cURL to automate HTTP jobs
http://curl.haxx.se/docs/httpscripting.html

You can do a lot of this via newLISP's get-url function once you understand the method... But for https protected sites you need to use cURL...

Note: It helps greatly to first write a html interface page that accesses your database using GET, POST, or PUT html FORM methods to help debug your cgi request code and it's generated report via your browser... To access a foreign web site, use your browser's view source function to see the FORM code on the request page... (Yes, this can be a nightmare to try and read ;o)

Then use xml-parse and/or find-all to harvest your data from the returned report page... This can be as complex as an xml document, or as simple as a plain text one line per entry document, and doesn't need to be in encoded as html...

-- xytroxon

P.S. Yes, it's a lot of work ;o)
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

jazper
Posts: 92
Joined: Thu Dec 10, 2009 8:26 am
Location: South Africa

Re: "secret" save of game scores

Post by jazper »

Thanks for all the inputs and help - I think I can make a start on this with all this guidance. Much appreciated.

jazper
Posts: 92
Joined: Thu Dec 10, 2009 8:26 am
Location: South Africa

Re: "secret" save of game scores

Post by jazper »

I see I forgot some detail when thanking Lutz and xytotron:
  • 1. I am going to program the GET/POST from an Android phone game app.
    2. For now I am using a very simple game just to test saving and retrieving scores.
    3. The test game is written in Basic4Android - but it will be fun to try a rewrite in newLISP on Android once I have it all specced and done - by then I may have a better idea of what can and can't be done with newLISP on Android
    4. The scores are on my web site (currently developing that on my pc)

Locked