Send a game attribute as POST request to server

brainyprb

  • Posts: 4
I have gone through http://www.stencyl.com/help/view/web-requests/.
I have a game attribute called "score" which holds user's scores earned in the game.
After gameover I want to send those score to server in form of POST request and grab the data using a PHP page then save it to database and then i want to get the sites response back to game.
From Game Palette I chose Game and then web option.
Under HTTP Requests category I selected POST data ..... option


Above stuff is not working .please help me to send user score to server.

« Last Edit: October 17, 2014, 12:19:15 am by brainyprb »

gurigraphics

  • Posts: 690
Hi brainyprb,

The "POST data" only works on Stencyl version 2.x.

chrizt

  • Posts: 345
huh really? where did you know that the block is not working anymore on 3.x? is there any official post about that?
need help with behavior? game design? graphic design? just contact me
skype : christian.atin
email : christianatin27@gmail.com

gurigraphics

  • Posts: 690
Hi chrizt,
Yes, I too tested it.  Stencyl 2.2 (Actionscript) work: POST,  GET and REQUEST. Stencyl 3.0 and 3.1 (Haxe) nop.
Well, it seems that no one usually use.

captaincomic

  • *
  • Posts: 6108
Those blocks are supposed to work in 3.x too. What isn't working exactly?

chrizt

  • Posts: 345
i did used get block before on 3.x but its giving me an error on flash, is there any specific condition to use it?
need help with behavior? game design? graphic design? just contact me
skype : christian.atin
email : christianatin27@gmail.com

gurigraphics

  • Posts: 690
Quote
i did used get block before on 3.x but its giving me an error on flash, is there any specific condition to use it?
Has no mystery:
GET
http://community.stencyl.com/index.php/topic,264.msg2270.html#msg2270
POST
http://www.stencyl.com/help/view/web-requests/

Quote
Those blocks are supposed to work in 3.x too. What isn't working exactly?
The PHP does not receive the value of the variable with POST or GET. Only works in Stencyl 2.x.
Does the version of PHP? My version: 5.3.13

« Last Edit: October 23, 2014, 12:26:24 am by gurigraphics »

Husenica

  • Posts: 54
Using latest Stencyl version and POST works.
[POST data "score=10" to URL "http://.." and then do]

Read Web Requests on Stencyl Help (URL in previous post by gurigraphics)
"Note: For POST requests, you can pass in multiple fields at once by separating them with ampersands (&), like this:

name=John&id=123456"

Flash gives you error because of security

Go to Flash in Control Panel and under "Advenced" tab "Trusted Location Settings..."
Add "stencylworks" folder
C:/Users/Your User/AppData/Roaming/Stencyl/stencylworks/

chrizt

  • Posts: 345
Using latest Stencyl version and POST works.
[POST data "score=10" to URL "http://.." and then do]

Read Web Requests on Stencyl Help (URL in previous post by gurigraphics)
"Note: For POST requests, you can pass in multiple fields at once by separating them with ampersands (&), like this:

name=John&id=123456"

Flash gives you error because of security

Go to Flash in Control Panel and under "Advenced" tab "Trusted Location Settings..."
Add "stencylworks" folder
C:/Users/Your User/AppData/Roaming/Stencyl/stencylworks/

this is very useful to know, i didnt know why it was giving error on flash, i know it was about security but didnt know how to solve it before
need help with behavior? game design? graphic design? just contact me
skype : christian.atin
email : christianatin27@gmail.com

sdieters

  • Posts: 2068
Can someone explain me a bit more about how the variables are being saved. Cause i tried posting to the same text file as i recieve from but thatbdidnt seem to work. I myst admit tho that i never worked with php but hope to learn this asap.
My new profile is TheIndieStation.
When you see a recent post with this name, i'm probably using my phone. So dont mind any typo's =p

Innes

  • *
  • Posts: 1960
I've got a sample app and PHP code, but I can't access it until tomorrow. It's very straightforward to use, but it requires a MySQL server.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

chrizt

  • Posts: 345
i will be glad if you can share it innes,  did you manage to make an something like online save system with that?
need help with behavior? game design? graphic design? just contact me
skype : christian.atin
email : christianatin27@gmail.com

Innes

  • *
  • Posts: 1960
i will be glad if you can share it innes,  did you manage to make an something like online save system with that?

It's just a proof-of-concept prototype. It can write to, and read from a MySQL database, so it will be possible to create an online save system with it.

I'll try to dig it out tomorrow.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

chrizt

  • Posts: 345
do you happen to know about setting up the security for the server too? i have no idea about server programming
need help with behavior? game design? graphic design? just contact me
skype : christian.atin
email : christianatin27@gmail.com

vvitek

  • Posts: 118
I'll try to dig it out tomorrow.

Any chance for that sample? Thanks in advance!