This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Rewrite Curl to LUA?
#5
Code:
1234567891011121314151617181920212223242526272829303132333435363738394041
http = require('socket.http') ltn12 = require('ltn12') json = require('json') function dorequest(url, headers, data)   local resp = {}   headers['Content-Length'] = #data   local res, err = http.request({     url = url,     method = 'POST',     headers = headers,     sink = ltn12.sink.table(resp),     source = ltn12.source.string(data)   })   if res then     return table.concat(resp)   else     return nil, err   end end url = 'http://api.kairos.com/detect' imageurl = 'http://...' app_id = 'YOUR_APP_ID' app_key = 'YOUR_APP_KEY' headers = {   ['Content-Type'] = 'application/json',   ['app_id'] = app_id,   ['app_key'] = app_key, } data = json.encode({   ['image'] = imageurl }) res, err = dorequest(url, headers, data) log(res, err)
Reply


Messages In This Thread
Rewrite Curl to LUA? - by zoltan - 14.09.2017, 15:14
RE: Rewrite Curl to LUA? - by admin - 15.09.2017, 07:37
RE: Rewrite Curl to LUA? - by zoltan - 15.09.2017, 16:01
RE: Rewrite Curl to LUA? - by DGrandes - 21.08.2018, 08:38
RE: Rewrite Curl to LUA? - by admin - 21.08.2018, 12:06
RE: Rewrite Curl to LUA? - by DGrandes - 22.08.2018, 07:24

Forum Jump: