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