--本部分功能,适用于客户端和服务器

--服务器端使用
--serv:use(luaid(), "tb_json")

--客户端中使用
ui:use("tb_json")
local m_json=rxi_new_json()

--http get功能
function test_get()
    local outTNS = CTNString();


    local sURL=[[http://192.168.1.3:9851/action/test?file=uums_login&cmd=uums_login&user=sysadmin&pass=81dc9bdb52d04dc20036dbd8313ed055&to_json=1]];

    cutil:httpGet(sURL, outTNS);
    --m_pMyLog:print2txt(outStr)
    local outStr = outTNS:get();
    print(cutil:u2a(outStr));

end

--http post 带参数,和头信息
function test_post_param()
    local outTNS = CTNString();
    local sCParamS = CParamString()
    sCParamS:add('Content-Type:application/json;charset=UTF-8');


    local sURL=[[http://192.168.1.3:9851/action/test]];


?    

    local tbInParam={}    
    tbInParam['file']='uums_login';
    tbInParam['cmd']='uums_login';
    tbInParam['user']='sysadmin';
    tbInParam['pass']='81dc9bdb52d04dc20036dbd8313ed055';
    tbInParam['to_json']='1';

    local sInJson=m_json.encode(tbInParam) 

    cutil:httpPostWithHead(sURL, outTNS, sInJson,sCParamS);
    --m_pMyLog:print2txt(outStr)
    local outStr = outTNS:get();
    print(cutil:u2a(outStr));

end
test_post_param();
Copyright © TouchNet 2015 all right reserved,powered by Gitbook最后修订时间: 2022-06-21 09:21:04

results matching ""

    No results matching ""