函数:httpPost 提交网页数据

函数名称:提交网页数据

函数功能:以 post 方式提交数据获取网页返回信息

函数方法

str = httpPost(url,data,options)

参数 类型 必填 说明
url string 访问的网页地址 URL
data string 要提交的 Post 参数数据
options table 仅 TSLib v1.2.8 及其以上版本支持,操作参数

options 参数介绍

参数 类型 必填 说明
tstab number 参数需要写为 1,不可修改
timeOut number 超时时间,不写默认为 5 秒
urlEnCode boolean 仅 TSLib v1.2.8 及其以上版本支持
是否对 URL 进行编码。默认 false
false - 不进行编码,true - 进行编码
返回值 类型 说明
str string/boolean 成功返回网页内容,失败返回 false

函数用例

require "TSLib"--使用本函数库必须在脚本开头引用并将文件放到设备 lua 目录下
local url = "http://openapi.touchsprite.com/api/openapi"
local data = [[{"action": "getAuth","key": "vvvv","devices": ["be3fe1f8ed4edc0b02e206a96d9a73ddd"],"valid": 3600,"time": ]].. os.time() ..[[}]]
local options = {
    ["tstab"] = 1, -- 必填项
    ["timeOut"] = 90,
    ["urlEnCode"] = false
}
str = httpPost(url, data,options)
if str and str ~= "" then
    dialog(str)
end
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""