メインコンテンツまでスキップ

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 はデフォルトで自動的にエスケープされますが、最後の引数が true の場合は除きます
nLog(r)

c, h, r = http.post('https://httpbin.org/post', 10, {}, form) -- POST でフォームを送信します
nLog(r)