我正在尝试向带有一些参数的地址发送 POST 请求。该应用程序正在港口等待,根本没有前进。我做错了什么,我该如何解决这个问题?
Sub LoginUser()
obj = {}
obj.username = "scb@test.com"
obj.password = "123456"
loginUrl = "http://www.test.com/scb@test.com/"
request = CreateObject("roUrlTransfer")
port = CreateObject("roMessagePort")
request.SetUrl(loginUrl)
request.AddHeader("Content-Type", "application/x-www-form-urlencoded")
user = {}
date = CreateObject("roDateTime")
ba = CreateObject("roByteArray")
time = date.asSeconds().ToStr()
ba.FromAsciiString("login|test|"+ obj.username + time)
digest = CreateObject("roEVPDigest")
digest.Setup("md5")
digest.Update(ba)
hash = digest.Final()
param = "custId=test&subId=" + obj.username + "&password=" + obj.password + "&ver=1&time="+ time + "&sig=" + hash
if (request.AsyncPostFromString(param))
while (true)
msg = wait(0, port)
if (type(msg) = "roUrlEvent")
code = msg.GetResponseCode()
if (code = 200)
user = ParseJSON(msg.GetString())
if (user.id = -1)
DisplayLoginErrorMessage()
else
print user
end if
endif
else if (event = invalid)
request.AsyncCancel()
endif
end while
end if
End Sub