public class YunSms
{
public static bool Send(string mobile, string content = "", int templateid = 8467)
{
bool r = false;
string AppKey = "xxx";
string AppSecret = "xxx";
string t1 = Dates.timeStamp().ToString();
string Nonce = Fun.GetShortNo;
string cs = Security.Sha1(AppSecret + Nonce + t1);
Hashtable ht = new Hashtable();
ht["AppKey"] = AppKey;
ht["CurTime"] = t1;
ht["CheckSum"] = cs;
ht["Nonce"] = Nonce;
string smsret = "";
if (string.IsNullOrEmpty(content))
{
smsret = Remote.GetPostResult("https://api.netease.im/sms/sendcode.action", "mobile=" + mobile, ht);
}
else
{
if (content.IndexOf("\"") == -1)
{
content = "\"" + content + "\"";
}
smsret = Remote.GetPostResult("https://api.netease.im/sms/sendtemplate.action",
"templateid=" + templateid + "&mobiles=[\"" + mobile + "\"]¶ms=[" + content + "]", ht);
}
//Log.Write(smsret, "smsret");
YunSmsRet sr = Json.ParseFromJson<YunSmsRet>(smsret);
//Log.Write(sr.code, "sr.code");
if (sr.code == 200)
{
r = true;
}
return r;
}
public static bool verifycode(string mobile, string code)
{
bool r = false;
string AppKey = "xxx";
string AppSecret = "xxx";
string t1 = Dates.timeStamp().ToString();
string Nonce = Fun.GetShortNo;
string cs = Security.Sha1(AppSecret + Nonce + t1);
Hashtable ht = new Hashtable();
ht["AppKey"] = AppKey;
ht["CurTime"] = t1;
ht["CheckSum"] = cs;
ht["Nonce"] = Nonce;
string smsret = Remote.GetPostResult("https://api.netease.im/sms/verifycode.action",
"mobile=" + mobile + "&code=" + code, ht);
//Log.Write(smsret, "smsret");
YunSmsRet sr = Json.ParseFromJson<YunSmsRet>(smsret);
//Log.Write(sr.code, "sr.code");
if (sr.code == 200)
{
r = true;
}
return r;
}
}