I’ve corona sdk since 2017 but, I’ve never done anything with the network request. I’m currently building a HTML 5 game that requires getting and updating information ona server and using it to determine the player’s progression.
For example, I create a variable called “openStages”, an integer which determines the number of stages opened at the level selection page, if the players opens two stages, then this variable is equal to (2), then I send this number to a server and next time the player opens the game, this variable is called from the server and used to determine the number of stages that should be opened.
I’ve gone through the network request API and I can’t seem to get it working. Here’s an example below. Please how do I get this working.
local function networkListener( event )
if ( event.isError ) then
print( "Network error: ", event.response )
else
print ( "RESPONSE: " … event.response )
end
end
local headers = {}
local body = “Hello”
local params = {}
params.headers = headers
headers[“Username”] = “soccerrtest”
headers[“Password”] = “htqry”
params.body = body
Your code seems to be set up in a way that everything should work, so what do you mean when you say that it doesn’t work? Is it that you don’t get any response in your console? Is it only not working on your server? Or is it not returning what you expected it to return?
Also, please use the code formatting tools.
In the code that you posted, there’s no mention of this openStages variable that you are supposed to be sending. We also have no idea what your server is supposed to do, etc. Essentially, the code that you’ve provided should work exactly as it is written, you make a network request and you get something back.
The question is: what are you expecting to happen?
The hash formular is sha512(username+password+hashkey)
This was the information I got from the network guys, I’ve never used an Hashkey before, I don’t even know how to arrange this. I’ve been battling it for weeks, I’m almost at the point of giving up.
Given the information above, How do I structure the code to get the payload at that endpoint, what would the code look like ?
But the real issue is still how the back end works, i.e. what information does it actually expect to be passed, in what manner, and what information will it then return, etc.
You just need to read the documentation for whatever service you are using as your back end.