标签:lua socket
--lua代码
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)
//php测试代码
<?php
$arr = $_POST ;
$str = $arr[‘parameter‘];
file_put_contents("t.txt", print_r(json_decode($str),1));
echo $str;
?>
本文出自 “纯技术纯探讨” 博客,请务必保留此出处http://hjun169.blog.51cto.com/3600246/1543143
标签:lua socket
原文地址:http://hjun169.blog.51cto.com/3600246/1543143