记录一下易语言post get使用WinHttp的操作

最近在学易语言,在进行通讯的时候,出现一些问题,现在记录下来,避免以后继续忘记,

先声明文本型变量jsonPostData

bash 复制代码
jsonPostData = "{'hostname':" + hostnameTxt + ",'hardcode':" + hardcodeTxt + ","
jsonPostData = jsonPostData + "'deviceid':" + md5code + ","
jsonPostData = jsonPostData + "'username':" + username.内容 + ","
jsonPostData = jsonPostData + "'authcode':" + authcode.内容
jsonPostData = jsonPostData + "}"

jsonPostData = 子文本替换 (jsonPostData, "'", #引号, , , 真)

.变量搞定了

然后声明一个对象变量httpObj

post方法如下:

bash 复制代码
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 方法如下:

bash 复制代码
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.清除 ()

亲自测试能通过,稳稳的在运行

相关推荐
郑州光合科技余经理12 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
feifeigo12313 天前
matlab画图工具
开发语言·matlab
dustcell.13 天前
haproxy七层代理
java·开发语言·前端
norlan_jame13 天前
C-PHY与D-PHY差异
c语言·开发语言
多恩Stone13 天前
【C++入门扫盲1】C++ 与 Python:类型、编译器/解释器与 CPU 的关系
开发语言·c++·人工智能·python·算法·3d·aigc
QQ40220549613 天前
Python+django+vue3预制菜半成品配菜平台
开发语言·python·django
遥遥江上月13 天前
Node.js + Stagehand + Python 部署
开发语言·python·node.js
m0_5312371713 天前
C语言-数组练习进阶
c语言·开发语言·算法
Railshiqian13 天前
给android源码下的模拟器添加两个后排屏的修改
android·开发语言·javascript
雪人不是菜鸡13 天前
简单工厂模式
开发语言·算法·c#