I am trying to send a POST request to an address with some parameters. The app is waiting on the port and not moving forward at all. What am I doing wrong and how do I fix this?
Sub LoginUser()
obj = {}
obj.username = "scb@test.com"
obj.password = "123456"
loginUrl = "http://www.junctiontv.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|cdigm|"+ obj.username + time)
digest = CreateObject("roEVPDigest")
digest.Setup("md5")
digest.Update(ba)
hash = digest.Final()
param = "custId=cdigm&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