编码 HTTP URLENCODED 表单 (http.table_to_form_urlencoded)
声明
编码好的表单文本 = http.table_to_form_urlencoded(需要编码的表)
参数
- 需要编码的表
表型
返回值
- 编码好的表单文本
文本型
说明
这个函数在 20250313 以后版本方可使用
示例
form = http.table_to_form_urlencoded{
num = 1,
str = '你好',
arr = {12, 34, '好'},
}
nLog(form) -- arr%5B0%5D=12&arr%5B1%5D=34&arr%5B2%5D=%E5%A5%BD&str=%E4%BD%A0%E5%A5%BD&num=1
c, h, r = http.get('https://httpbin.org/get?'..form, 10, {}, true) -- 通过 GET Query 提交表单,URL 默认会自动 Escape,除非最后一个参数是 true
nLog(r)
c, h, r = http.post('https://httpbin.org/post', 10, {}, form) -- 通过 POST 提交表单
nLog(r)