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! Notification SMS from LM using Twilio service
#9
(15.10.2019, 13:53)admin Wrote: Replace sms function with this one:
Code:
function sms(id, token, from, to, body)
  local escape = require('socket.url').escape
  local request = require('ssl.https').request
  local url = string.format('https://%s:%s@api.twilio.com/2010-04-01/Accounts/%s/Messages.json', id, token, id)
  local body = string.format('From=%s&To=%s&Body=%s', escape(from), escape(to), escape(body))
  local resp = {}
  local stat, code, hdrs = request({
    method = 'POST',
    url = url,
    protocol = 'tlsv12',
    sink = ltn12.sink.table(resp),
    source = ltn12.source.string(body),
    headers = {
      ['content-length'] = #body,
      ['content-type'] = 'application/x-www-form-urlencoded'
    }
  })

  if stat then
    stat = table.concat(resp)
  end

  return stat, code, hdrs
end

It's working!! Thank you so much Smile

But it takes about 15 min for 1 SMS, too long
Reply


Messages In This Thread
RE: Help me! Notification SMS from LM using Twilio service - by cuong.nguyen@vis.solutions - 16.10.2019, 10:21

Forum Jump: