The title pretty much says it all.
I think this may be possible with network.request().
Again, what I’m wondering is:
can I post variables to a php file and retrieve them with $_POST in the php file?
The title pretty much says it all.
I think this may be possible with network.request().
Again, what I’m wondering is:
can I post variables to a php file and retrieve them with $_POST in the php file?
This might get you started:
http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/
Rob
Rob’s article has a lot more info … the simple approach is:
local urlfuncs = require( "socket.url" ) print("sending to server") local auxdata = {} auxdata.headers = {} auxdata.headers["Authorization"] = "Basic "..mime.b64("username:password") auxdata.headers["Content-Type"] = "application/x-www-form-urlencoded" auxdata.body = "m="..urlfuncs.escape(txt) function listener\_func( e ) -- do something here end network.request( remote\_host, "POST", listener\_func, auxdata )
On the php side, I used _REQUEST:
$fp = fopen( "logfile.txt", "a" ); if( flock($fp,LOCK\_EX) ) { $txt = date('Y-m-d-H:i:s') . ' (' . $\_ENV['REMOTE\_ADDR'] . ') '; if( $\_REQUEST['m'] != '' ) { $txt .= $\_REQUEST['m'] . ' '; } $txt .= "\n"; fwrite( $fp, $txt ); flock( $fp, LOCK\_UN ); } else { print "\* Error: could not lock file\n\n"; } fclose( $fp );
I used “m=…” to send data between the two, but any variable would obviously work.
Thanks guys!
This might get you started:
http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/
Rob
Rob’s article has a lot more info … the simple approach is:
local urlfuncs = require( "socket.url" ) print("sending to server") local auxdata = {} auxdata.headers = {} auxdata.headers["Authorization"] = "Basic "..mime.b64("username:password") auxdata.headers["Content-Type"] = "application/x-www-form-urlencoded" auxdata.body = "m="..urlfuncs.escape(txt) function listener\_func( e ) -- do something here end network.request( remote\_host, "POST", listener\_func, auxdata )
On the php side, I used _REQUEST:
$fp = fopen( "logfile.txt", "a" ); if( flock($fp,LOCK\_EX) ) { $txt = date('Y-m-d-H:i:s') . ' (' . $\_ENV['REMOTE\_ADDR'] . ') '; if( $\_REQUEST['m'] != '' ) { $txt .= $\_REQUEST['m'] . ' '; } $txt .= "\n"; fwrite( $fp, $txt ); flock( $fp, LOCK\_UN ); } else { print "\* Error: could not lock file\n\n"; } fclose( $fp );
I used “m=…” to send data between the two, but any variable would obviously work.
Thanks guys!