跳至主要內容

編碼 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)