最近在学易语言,在进行通讯的时候,出现一些问题,现在记录下来,避免以后继续忘记,
先声明文本型变量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 方法如下:文章来源:https://www.toymoban.com/news/detail-854253.html
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.清除 ()
亲自测试能通过,稳稳的在运行文章来源地址https://www.toymoban.com/news/detail-854253.html
到了这里,关于记录一下易语言post get使用WinHttp的操作的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!