lua-users home
lua-l archive

luacurl, how to post with OPT_HTTPPOST?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


hello and happy xmas.
after some confusion between lua-CURL and lua-cURL,
i try to understand how to send a POST using lua-curl.
i want to simulate something like
curl -d "article[title]=hello world&article[body]=this is my text"
https://mycms.com/new
i use a function like this to send the request and fetch the response
(as found on this list before)
function fetch(url)
 local text = {}
 local function WriteMemoryCallback(s)
 text[#text+1] = s
 return string.len(s)
 end
 local c = curl.easy_init()
 c:setopt(curl.OPT_URL, url)
 c:setopt(curl.OPT_WRITEFUNCTION, WriteMemoryCallback)
 c:setopt(curl.OPT_USERAGENT, "luacurl-agent/1.0") c:perform()
 return table.concat(text,'')
end
now i found in the documentation that there is the option
curl.OPT_HTTPPOST , but whatebver option i set, table or string,
it always tells me "table expected, not string".
or do i look into the wrong option here?
so i am a bit lost ... as a word of warning, im not a wizard with
libcurl itself so i know little about the internas.
startx

AltStyle によって変換されたページ (->オリジナル) /