Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

PostAsync not seeming to work?

I'm trying to post some data to a site, and if there is data it'll echo "posted", if not it'll echo "not posted". However, when using this, I try to post data to the site and it always does "not posted".

Here's my php code: if (!empty($_POST)){ echo'posted' } else { echo'not posted'}

Here's my lua code: print(game:GetService("HttpService"):PostAsync("http://local??host/tutorial/index.??php","test"))

Thanks so much!

1 comment

0

Use code blocks for code. And what are you even doing exactly?

1 answer

AFAIK, the $_POST variable in PHP is only used for form encoded post values (i.e., a format used by HTML forms, and not by your code here)

Use $postdata = file_get_contents("php://input"); to get the full contents of the posted message.

2 comments

0

Thank you, this works. However, let's say I post a table. When I try to index the table from PHP it just returns the index of the string. How would I get an index from a table which was posted, rather than a string?

0

...you can't, PHP isn't Lua, there are no tables. You have to parse it. Most likely serialize as JSON at the Lua and and parse as JSON in the PHP end.

This discussion is preserved as it was. New answers, comments, and votes are closed.