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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 26 Jan 2015 05:38 AM |
file_get_contents("php://input")
thats how I did it |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
|
| 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
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|
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
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 26 Jan 2015 01:06 PM |
| pretend like i put ; at the end |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 26 Jan 2015 01:13 PM |
| By default, POST from ROBLOX are set to application/json |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|