--lua代碼
php
local http = require "socket.http"
local ltn12 = require("ltn12")
request_body = 'u=1¶meter={"m":"S"}'
local result = http.request{
url = "http://127.0.0.1/2.php",
sink = ltn12.sink.file(io.stdout),
method = "POST",
headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
["Content-Length"] = #request_body,
},
source = ltn12.source.string(request_body)
}
print (result)json
//php測試代碼app
<?php
$arr = $_POST ;
$str = $arr['parameter'];
file_put_contents("t.txt", print_r(json_decode($str),1));
echo $str;
?>socket