How do I create and send a json POST request to a URL?

Get help using Construct 2

Post » Wed Jun 10, 2015 3:20 am

Hello,

I'm very new to Construct 2, but I'm an experienced programmer. I'm researching Construct 2 because I have an aversion to JavaScript, but I need to make a commercial web game for a business.

I'm trying to learn how one might use Construct 2's interface to dynamically build a json string containing variables from a game session, send it to a URL, receive a json response, and access the content of the json.

In Unity and Unreal Engine, this is a piece of cake, but those engines are too heavy for my needs, and their HTML5/JS export is still very experimental. (Plus, ya know, royalties).

Say for instance I have a login page, with two fields: Username, Password. The user fills these in. How would I go about plugging those values into a json string, to end up with this?

Code: Select all
{
    login : {
        username : "abc",
        password : "123"
    }
}


And once I have that, I need to send it to my server and receive the json response containing an authentication token, which will be used for all subsequent requests.

I will need to know if the request succeeded/failed and any associated error codes as well.

Is this possible in the current version of Construct 2?

Thanks.
B
12
S
4
Posts: 48
Reputation: 910

Post » Wed Jun 10, 2015 5:33 am

I dont worked with ajax like this, but I would try it like one of these examples. Not tested!

Image

Problem with this examples, my Tools plugin is also very experimental. :D
But I think there are other stable plugins for json... Search...
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
10
S
4
G
1
Posts: 158
Reputation: 1,303

Post » Wed Jun 10, 2015 1:42 pm

Thanks for the response. I will do some research into the AJAX object and try to find any simple JSON plugins.
B
12
S
4
Posts: 48
Reputation: 910

Post » Wed Jun 10, 2015 2:48 pm

I find mine most simple and flexible, but I think because I know every function.
It's just not completly done yet and I adjust to my project if needed.
I cant explain it, because Im not good in and my bad english... But that you see in description. :lol:
Actually, we do almost the same.
The only difference, my server is Smartfox.
I have to work with quite large json, with 10+ entrys and deep of 5+, like "params.characters[0].look.hair.color" as one entry.
Exactly for this I build my plugin.
With the other json plugins I have found, I had problems.
If you find a good one to handle json in/output, let me know...
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
10
S
4
G
1
Posts: 158
Reputation: 1,303


Return to How do I....?

Who is online

Users browsing this forum: stevenode, tarek2 and 8 guests