最近在学易语言,在进行通讯的时候,出现一些问题,现在记录下来,避免以后继续忘记,
先声明文本型变量jsonPostData
jsonPostData = “{'hostname':” + hostnameTxt + “,'hardcode':” + hardcodeTxt + “,”
jsonPostData = jsonPostData + “'deviceid':” + md5code + “,”
jsonPostData = jsonPostData + “'username':” + username.内容 + “,”
jsonPostData = jsonPostData + “'authcode':” + authcode.内容
jsonPostData = jsonPostData + “}”jsonPostData = 子文本替换 (jsonPostData, “'”, #引号, , , 真)
.变量搞定了
然后声明一个对象变量httpObj
post方法如下:
httpObj.创建 (“WinHttp.WinHttpRequest.5.1”, )
httpObj.方法 (“SetTimeouts”, 3000, 3000, 3000, 3000)
httpObj.方法 (“Open”, “POST”, postUrl, 假)
httpObj.写属性 (“Option”, 6, 0)
httpObj.写属性 (“Option”, 4, 13056)
httpObj.方法 (“SetRequestHeader”, “content-type”, “application/json”)
httpObj.方法 (“SetRequestHeader”, “content-length”, 取文本长度 (jsonPostData))
httpObj.方法 (“Send”, jsonPostData)
resTxt = httpObj.读文本属性 (“ResponseText”, )
responseCode = httpObj.读数值属性 (“Status”, )
httpObj.清除 ()
get 方法如下:
postUrl = baseUrl + “/getkefuaccout”
httpObj.创建 (“WinHttp.WinHttpRequest.5.1”, )
httpObj.方法 (“SetTimeouts”, 3000, 3000, 3000, 3000)
httpObj.方法 (“Open”, “GET”, postUrl, 假)
httpObj.写属性 (“Option”, 6, 0)httpObj.方法 (“SetRequestHeader”, “content-type”, “application/json”)
httpObj.方法 (“Send”, )
resTxt = httpObj.读文本属性 (“ResponseText”, )
httpObj.清除 ()
亲自测试能通过,稳稳的在运行