Web form

local Http = GameNet.Http
local json = require 'cjson'
local root = "http://localhost/zentaopms/www/"
Http.Get(root.."?m=api&f=getSessionID&t=json", function(err, content)
 print(err, "------step1------", content)   
    local aa = json.decode(content)
    print("----1")
    print(aa.data)
    print("----2")
    local bb = json.decode(aa.data)
    --print(bb)
    local url = string.format(root.."?m=user&f=login&t=json&sid=%s&account=admin&password=admin", bb.sessionID)
    Http.Get(url, function(err, content)
        print(err, "------step2------", content)
        local url2 = string.format(root.."?m=bug&f=create&t=json&sid=%s&deptID=0", bb.sessionID)
        local datas = {fields={}}
        datas.fields.product = "2"
        datas.fields.module = "0"
        datas.fields.steps = 'hello'
        datas.fields.title = 'title2'
        datas.fields.openedBuild = "trunk"
        datas.fields.assignedTo = "T:测试经理"
        local val = json.encode(datas)
        print(val)
        Http.Post(url2, val, function(err, content)
            print(err, "------step3------", content)
        end, 5)
    end, 5)
end, 5)

你可能感兴趣的:(Web form)