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.

Help me to send a simple HTTP post
#2
Try this, change data inside encodepost table as needed:
Code:
require('socket.http')

function encodepost(t)
  local res = {}
  local esc = require('socket.url').escape

  for k, v in pairs(t) do
    res[ #res + 1 ] = esc(k) .. '=' .. esc(v)
  end

  return table.concat(res, '&')
end

url = 'https://oauth.hanet.com/token'

payload = encodepost({
  code = 'CODE',
  grant_type = 'authorization_code',
  client_id = 'CLIENT_ID',
  redirect_uri = 'HTTP_CALLBACK_URL',
  client_secret = 'CLIENT_SECRET',
})

res, err, headers, status = socket.http.request(url, payload)
log(res, err, headers, status)
Reply


Messages In This Thread
RE: Help me to send a simple HTTP post - by admin - 12.07.2021, 15:07

Forum Jump: