--http get 最简单的数据获取
local sBuf = CTNString();
cutil:httpGet('http://www.baidu.com',sBuf);
local sValue = cutil:u2a(sBuf:get());
print(sValue);



--http post 带参数
local sBuf = CTNString();
local sParam = [[
    {"from_account":"9298292829292828"}
]];
cutil:httpPost('http://122.225.94.70:8080/MDDataService/jaxrs/webclientrest/getToken',sBuf,sParam);
local sValue = cutil:u2a(sBuf:get());
print(sValue);

--http post 带头部信息,带Json参数
local sParam = [[
    {"accesstoken":"9298292829292828",
    "classname":"SRM_Box",
    "method":"getBoxMsg",
    "content":{
                "BoxCode":"abc"
            }
    }
]];
local sURL=[[http://122.225.94.70:8080/MDDataService/jaxrs/webclientrest]];
local paramList = CParamString()
paramList:add(cutil:a2u('Content-Type:application/json;charset=UTF-8'));
print('post request erp param: ' .. sParam)

local sBuf = CTNString();
cutil:httpPostWithHead(sURL,sBuf,sParam, paramList);
local sValue = cutil:u2a(sBuf:get());
print(sValue);
Copyright © TouchNet 2015 all right reserved,powered by Gitbook最后修订时间: 2022-06-21 09:21:04

results matching ""

    No results matching ""