函数:ts.httpsPost 发送 httpsPOST 请求

函数名称:发送 httpsPOST 请求

函数功能:发送 httpsPOST 类型 请求

iOS 函数方法

code,header_resp,body_resp = ts.httpsPost(url,header_send, body_send);

参数 类型 必填 说明
url string 请求 URL
header_send table 请求头部内容,本参数必须与请求体一起填写
body_send table 请求内容,本参数必须与头部一起填写
返回值 类型 说明
code number 返回状态码
header_resp string 头部返回内容
body_resp string 返回内容

Android 函数方法

code,status_resp,body_resp = ts.httpsPost(url,tab)

参数 类型 必填 说明
url string 请求 URL
tab table table 参数

table 参数介绍

参数 类型 必填 说明
tstab string 只能为 tstab,不可修改
header_send table 请求头部内容,本参数必须与请求体一起填写
body_send table 请求内容,本参数必须与头部一起填写
format string 仅 Android ts.so v1.1.4 及其以上版本支持,
不写为不对返回值进行转码,
utf8 - 对 body_resp 进行 utf-8 格式转码,
gbk - 对 body_resp 进行 gbk 格式转码
返回值 类型 说明
code number 返回状态码
header_resp string 头部返回内容
body_resp string 返回内容

函数用例

--iOS 脚本实例
local ts = require("ts")
header_send = {typeget = "iOS"}
body_send = {
["username"] = "aa",
["password"] = "1234"
}
-- body : username=aa&password=1234
ts.setHttpsTimeOut(60) 
code,status_resp, body_resp = ts.httpsPost("https://www.baidu.com", header_send, body_send)
dialog(code,0)
dialog(header_resp,0)
dialog(body_resp,0)
--Android 脚本实例
local ts = require("ts")
--format 参数仅支持 Android ts.so v1.1.4 及其以上版本
--tstab = "tstab"此参数不嫩能修改
tab = {tstab = "tstab",header_send = {typeget = "android"} , body_send = {id = "687"} ,format ="gbk" }
code,header_resp, body_resp = ts.httpsPost("https://whois.pconline.com.cn/ip.jsp",tab)
dialog(code,0)
dialog(header_resp,0)
dialog(body_resp,0)

注意事项

  • 如果参数中有类似 “%E8%A7%A6%E5%8A%A8%E7%B2%BE%E7%81%B5” 的参数并且运行代码后发现和网络请求的结果不显示,请使用 urlDecoder 函数将此段代码编码后重新运行代码再试下。

  • 如果想上传图片或者文件可以使用函数: imageBase64编码后进行上传。

Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""