Ok, now that I was able to have 1 hour without a biting and pinching 1 year old on my lap I think I figured out a way to do this:).
My goal is to interface with a centralized database such as PostgreSQL to work on a multi-player drum role… tic tac toe game my daughter and I are working on. So if you have a Lua script with the contents below and a php script with the contents below I think it should work. Thanks to ehsmeng for this post to get me started [html]http://developer.anscamobile.com/code/post-json-data-and-receive-json-data-example[/html]
–START LUA
[lua]http = require(“socket.http”)
ltn12 = require(“ltn12”)
url = require(“socket.url”)
local post = “InputName=” … “Robot7001”
post = post … “&InputAge=” … “8”
local response = {}
local r, c, h = http.request {
url = "https://www.yoursite.com/TestPost.php?",
method = “POST”,
headers = {
[“content-length”] = #post,
[“Content-Type”] = “application/x-www-form-urlencoded”
},
source = ltn12.source.string(post),
sink = ltn12.sink.table(response)
}
print(response[1])[/lua]
–START PHP
[php]
<?php
if ( $\_POST[InputAge] \<= 30 )
echo ("You young " . $\_POST[InputName] . "." );
else echo ("You getting old" . $\_POST[InputName] . "!" );
?\>
[/php]
Hopefully this will be of value to someone wanting to talk to a php script or any web hosted script for that matter. At some point sending json or some other speced data will probably be a good idea and should be pretty easy with Lua and PHP.
I know for me this is one step closer to taking over the world with multi-player tic tac toe! [import]uid: 10640 topic\_id: 4452 reply\_id: 13955[/import]