| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- local M = {}
- local httpclient = require("httpclient")
- local sms_url = "https://api-v4.mysubmail.com/sms/xsend"
- local sms_world_url = "https://api-v4.mysubmail.com/internationalsms/xsend"
- M.send = function(phone,appid,appkey,signature,template_code,vars)
-
- local data = {
- appid = appid,
- signature = appkey,
- to = phone,
- project = template_code,
- vars = cjson.encode(vars),
- sms_signature = signature,
- }
- local result,msg = httpclient.post(sms_url,{
- ["Content-Type"] = "application/json",
- },cjson.encode(data))
-
- if result then
- local json = cjson.decode(msg)
- if json.status == "success" then
- return true
- else
- return false,json.msg
- end
- else
- return false,msg
- end
- end
- M.send_world = function(phone,appid,appkey,template_code,vars)
- local data = {
- appid = appid,
- signature = appkey,
- to = phone,
- project = template_code,
- vars = cjson.encode(vars)
- }
- print(cjson.encode(data))
- local result,msg = httpclient.post(sms_world_url,{
- ["Content-Type"] = "application/json",
- },cjson.encode(data))
-
- if result then
- local json = cjson.decode(msg)
- if json.status == "success" then
- return true
- else
- return false,json.msg
- end
- else
- return false,msg
- end
- end
- return M
|