lua post

时间:2014-08-21 19:41:35   收藏:0   阅读:774

--lua代码

local http = require "socket.http"
local ltn12 = require("ltn12")
request_body = ‘u=1&parameter={"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 post,布布扣,bubuko.com

原文:http://hjun169.blog.51cto.com/3600246/1543143

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!