|
- 按键工程师
- 742060
- 2281
- 5
- 881 朵
- 10799 个
- 580 个
- 48300
- 2011-08-18
|
1#
t
T
发表于 2021-11-26 18:49
|
|只看楼主
现在官方自带的http的命令少了个提交文件的功能,美中不足¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê无可奈何我就被迫营业封装了一个http的插件,可以支持upload功能¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê目前插件还是内测版本,功能不完善且概率存在一定BUG,后续会进行迭代更新¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
功能特色¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 自定义header消息头¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 智能判定Content-Type类型¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 支持Android&IOS双端使用¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 统一的payload格式传入(table类型)¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê命令功能¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uêSHTTP.Get(url, opts)¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 功能:发送Get请求¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 参数:¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- url: 必选,请求的url¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- opts: 可选参数,包含以下参数的键值表headers: 自定义http消息头,可以是键值表或者字符串timeout: 请求超时时间,默认为10秒files: 上传文件路径¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 返回:返回请求结果¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uêSHTTP.Post(url, data, opts)¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 功能:发送Get请求¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 参数:¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- url: 必选,请求的url¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- data: 必选,需要提交的请求数据,用键值表或者key-value存放提交数据¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- opts: 可选参数,包含以下参数的键值表headers: 自定义http消息头,可以是键值表或者字符串timeout: 请求超时时间,默认为10秒files: 上传文件路径¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- 返回:返回请求结果¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê使用范例¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê简单的Get网页- Import "SHTTP.lua"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- TracePrint SHTTP.Get("http://bbs.anjian.com/")¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
复制代码 附带请求头Get- Import "SHTTP.lua"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- Dim tHeaders = {null}¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
复制代码 发送post请求- Import "SHTTP.lua"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- Dim sUrl= "https://api.toolnb.com/Tools/Qrcode/qrcodeLogo.html"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
复制代码- Import "SHTTP.lua"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- Dim tHeaders = {null}¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- tHeaders["user-agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
复制代码 通过post来提交文件- Import "SHTTP.lua"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- Dim sUrl= "https://api.toolnb.com/Tools/Qrcode/qrcodeLogo.html"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
复制代码 ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê对接百度OCR识别API- Dim sUrl = "https://aip.baidubce.com/oauth/2.0/token"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- Dim tData = {null}¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- tData["grant_type"] = "client_credentials"¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- tData["client_id"] = "" // 填自己的client_id¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- tData["client_secret"] = "" // 填自己的client_secret¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- Dim sJson, tJson¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- // 获取api的access_token值¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- sJson = SHTTP.Post(sUrl, tData)¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- tJson = Cjson.Decode(sJson)¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- Dim Access_Token = tJson["access_token"]¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- sUrl = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic" & "?access_token=" & Access_Token¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- // 需要先将图片转成base64编码¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- Dim ImgBase64 = ShanHai.ReadFileBase(GetSdcardDir() & "/Pictures/test.png")¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- // 对内容进行url编码¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- ImgBase64 = ShanHai.CharToUrl(ImgBase64)¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- sJson = SHTTP.Post(sUrl, {"image":ImgBase64},{"headers":{"Content-Type":"application/x-www-form-urlencoded"}})¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- tJson = Cjson.Decode(sJson)¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- For i = 1 To Len(tJson["words_result"])¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- TracePrint tJson["words_result"][i]["words"]¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
- Next¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
复制代码 ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê插件开源下载(回复可见):¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê [attach]251160[/attach] ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê ¾´:^GBÊbbs.vrbrothers.comD®AÄÒt,uê
|