using System; using System.Collections.Generic; using System.Text; using WX.CRM.Common; using WX.CRM.CRMServices.SMS.InterfaceModel; namespace WX.CRM.CRMServices.SMS.InterfaceExec { public class QQSms : IMsgSend { public string url = ""; public string appid = ""; public string appkey = ""; public QQSms(string _account = "", string _password = "") { QQSmsConfig config = new QQSmsConfig(); //appid = config.appid; //appkey = config.appkey; appid = _account; appkey = _password; url = config.url; } public ReturnResult Execute(string[] mobiles, string msg) { return Send(mobiles, msg); } public decimal queryAmt() { throw new NotImplementedException(); } ReturnResult Send(string[] mobiles, string msg) { string mobilesStr = string.Join(",", mobiles); ReturnResult result = new ReturnResult(); result.SendStr = mobilesStr; string MessageContent = ToHex(msg, "GBK", false); //短信内容 List mobileList = new List(); //mobileList.Add(new Tels { nationcode = "86", phone = "18928851675" }); foreach (var mobile in mobiles) { mobileList.Add(new Tels { nationcode = "86", phone = mobile }); } QQSmsPrams parms = new QQSmsPrams(); parms.tel = mobileList; parms.msg = MessageContent; parms.type = "0"; string sig = Utility.EncryptMD5(appkey + mobilesStr); parms.sig = sig; var pstr = Utility.ObjectToJson(parms); Console.WriteLine("QQSms参数:[" + pstr + "]" + url); LogHelper.Info("QQSms参数:[" + pstr + "]"); var res = Utility.PostData(url, pstr, Encoding.UTF8); LogHelper.Info("QQSms结果:[" + res + "]"); result.ReturnStr = res; QQSmsResultModel resm = Utility.JSONToObject(res); if (resm.result == 0) //发送成功 result.submitStatus = SubmitStatus.success; else result.submitStatus = SubmitStatus.fail; return result; } string ToHex(string s, string charset, bool fenge) { byte[] buffer = Encoding.GetEncoding("GBK").GetBytes(s); s = Encoding.GetEncoding("GBK").GetString(buffer); return s; } } }