/// <summary> /// 发送短信接口 /// </summary> /// <param name="content"></param> /// <param name="numbers"></param> /// <param name="priority"></param> /// <returns></returns> public static bool SendSMS(string content, string[] numbers, int priority = 5) { //获取短信接口的序列号,和自定义Key string SerialNo = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_SerialNo"); string Key = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_Key"); if (String.IsNullOrWhiteSpace(SerialNo) || String.IsNullOrWhiteSpace(Key)) { LogHelp.AddErrorLog("亿美短信接口缺少企业序列号或者自定义关键字Key", "亿美短信接口调用失败", HttpContext.Current.Request); return(false); } SMSService.SDKClient sdkClient = new SDKClientClient(); sendSMSRequest smsRequest = new sendSMSRequest(); smsRequest.arg0 = SerialNo; smsRequest.arg1 = Key; smsRequest.arg3 = numbers; smsRequest.arg4 = YSWL.Common.Globals.HtmlEncode(content); smsRequest.arg7 = priority; sendSMSResponse smsResponse = sdkClient.sendSMS(smsRequest); if (smsResponse.@return == 0) { return(true); } string msg = SendSMSException(smsResponse.@return); LogHelp.AddErrorLog("亿美短信接口发送短信出现异常,【" + msg + "】,错误码【" + smsResponse.@return + "】", "亿美短信接口调用失败", HttpContext.Current.Request); return(false); }
/// <summary> /// 查询余额 /// </summary> public static double GetBalance() { string SerialNo = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_SerialNo"); string Key = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_Key"); if (String.IsNullOrWhiteSpace(SerialNo) || String.IsNullOrWhiteSpace(Key)) { LogHelp.AddErrorLog("亿美短信接口缺少企业序列号或者自定义关键字Key", "亿美短信接口调用失败", HttpContext.Current.Request); return(0); } try { SMSService.SDKClient sdkClient = new SDKClientClient(); getBalanceRequest request = new getBalanceRequest(SerialNo, Key); getBalanceResponse response = sdkClient.getBalance(request); return(response.@return); } catch (Exception ex) { LogHelp.AddErrorLog("查询短信余额异常:" + ex.Message, ex.StackTrace, HttpContext.Current.Request); throw; } }
/// <summary> /// 注册序列号 /// </summary> /// <returns></returns> public static bool Logout() { string SerialNo = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_SerialNo"); string Key = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_Key"); string Pwd = BLL.SysManage.ConfigSystem.GetValueByCache("Emay_SMS_Pwd"); if (String.IsNullOrWhiteSpace(SerialNo) || String.IsNullOrWhiteSpace(Key)) { LogHelp.AddErrorLog("亿美短信接口缺少企业序列号或者自定义关键字Key", "亿美短信接口调用失败", HttpContext.Current.Request); return(false); } SMSService.SDKClient sdkClient = new SDKClientClient(); logoutRequest request = new logoutRequest(SerialNo, Key); logoutResponse response = sdkClient.logout(request); if (response.@return == 0) { return(true); } string msg = LogoutException(response.@return); LogHelp.AddErrorLog("亿美短信注销序列号出现异常,【" + msg + "】", "亿美短信接口调用失败", HttpContext.Current.Request); return(false); }