Files
daydaytalk-fwutils/target/submail/sms.lua
2026-01-08 21:58:41 +08:00

56 lines
1.4 KiB
Lua

local M = {}
local httpclient = require("fwutils.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