Stig,
Sure. Let’s assume you want to get the total “coins” player17 has earned from your database. First you’ll you write a bunch of “web services” that can perform select’s, inserts, updates and deletes on your database. Now, let’s pretend you point your web browser at your web service for querying data about a player: http://example.com/players/player17
Instead of “html” your webservice should return json data that looks like this:
{
“playername” : “player17”,
“coins” : 153,
“location” : “AZ”
}
Cool, so how do you use that in Corona? Your App should do something like this (untested btw)…
[lua]local json = require “json”
local function networkListener( event )
if ( event.isError ) then
print( “Network error!”)
else
print ( "RESPONSE: " … event.response )
local t = json.decode(event.response)
print(t.playername) --> player17
print(t.coins) --> 153
end
end
– Access Your web service using HTTP
network.request( “http://example.com/players/player17”, “GET”, networkListener )[/lua]
P.S. Read about REST here: http://en.wikipedia.org/wiki/Representational_state_transfer
[import]uid: 60707 topic_id: 21253 reply_id: 85050[/import]