generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: HttpService PostAsync

Previous Thread :: Next Thread 
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
26 Jan 2015 03:11 AM
How does a webserver recieve the content? If I were to make a post request to a web server containing a user's name.

How do I find on the server what it recieved?

(If PostAsync don't do this, then let's be honest, what's the point of it?)
Report Abuse
BAUER102 is not online. BAUER102
Joined: 03 Apr 2010
Total Posts: 5936
26 Jan 2015 03:53 AM
The payload is stored in the body of the HTTP request, as per definition of a POST request.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
26 Jan 2015 04:09 AM
PostAsync is so confusing omg, put it like this though

If I were to post a string, can I print the string on the webserver? like, it comes in plain text o the webserver what I had in the post request? (I know PHP, I just don't get how I can do that (finding the post request))
Report Abuse
SethDusek5 is not online. SethDusek5
Joined: 26 Mar 2011
Total Posts: 2580
26 Jan 2015 05:38 AM
file_get_contents("php://input")

thats how I did it
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
26 Jan 2015 05:50 AM
Thanks.
Report Abuse
SethDusek5 is not online. SethDusek5
Joined: 26 Mar 2011
Total Posts: 2580
26 Jan 2015 05:57 AM
You're welcome, also some stuff that helped me:

Use JSON to transfer arrays whether it be lua to php or php to lua

Make sure to add a die(); to the end of your code so that it doesnt return anything else (it sometimes does, atleast it does on 000webhost)
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
26 Jan 2015 06:04 AM
Yeah of course. Hehe.
Report Abuse
gskw is not online. gskw
Joined: 05 Jan 2013
Total Posts: 1364
26 Jan 2015 07:50 AM
You shouldn't use a webhost like 000webhost. Try OpenShift or your own PC.

This is a signature. Recommended username: CrazyGskw
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
26 Jan 2015 11:29 AM
"your own PC"

what? My PC isnt a webserver e.e

openshift requires to make a key code, now whats stupid is that I have to download two programs to do that... :/
Report Abuse
BAUER102 is not online. BAUER102
Joined: 03 Apr 2010
Total Posts: 5936
26 Jan 2015 12:58 PM
"what? My PC isnt a webserver e.e"

then make it be a webserver?

forward a port, run apache. profit!
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
26 Jan 2015 12:59 PM
Run Nginx*
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
26 Jan 2015 01:00 PM
So I sent a ton of string to the webserver I want the server to print those

echo file_get_contents('php://input')


nothing prints, halp PHP users
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
26 Jan 2015 01:06 PM
pretend like i put ; at the end
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
26 Jan 2015 01:09 PM
What sort of data did you send? Can you show the exact post request?

If you sent, JSON, then you should be able to do:

$JSONReceived = file_get_contents("php://input");
print($JSONReceived);

$Array = json_decode($JSONReceived, true);
prinr_r($Array);
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
26 Jan 2015 01:10 PM
Since it was a string, I assumed I didn't have to JSONEncode or decode anything.....

I have to JSONEncode everything I send?
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
26 Jan 2015 01:13 PM
By default, POST from ROBLOX are set to application/json
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
26 Jan 2015 01:16 PM
test = {"Hello", "try dis"}

POSTreq = game:GetService("HttpService"):JSONEncode(test)

game:GetService("HttpService"):PostAsync("link", POSTreq)


will that do?
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
26 Jan 2015 01:17 PM
Looks like it should. Give it a go using the PHP code I gave you and see what the response is.
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
26 Jan 2015 01:18 PM
Only the first two lines of what I gave you at least. You should receive the same JSON table sent back to you.
Report Abuse
BAUER102 is not online. BAUER102
Joined: 03 Apr 2010
Total Posts: 5936
26 Jan 2015 01:18 PM
wrap the call to PostAsync in a print statement to see what it returns
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image