標籤:簽名 sub 沒有 div error ram setting 時間 content
1 public class Phone 2 { 3 /// <summary> 4 /// 日誌 5 /// </summary> 6 public static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 7 8 9 public static readonly string ServerAddress = ConfigurationManager.AppSettings["PhoneServerAddress"]; 10 public static readonly string Account = ConfigurationManager.AppSettings["PhoneUserName"]; 11 public static readonly string Pswd = ConfigurationManager.AppSettings["PhonePassword"]; 12 13 /// <summary> 14 /// 傳送簡訊 15 /// </summary> 16 /// <param name="mobile">手機號</param> 17 /// <param name="content">內容</param> 18 /// <param name="sign">簽名</param> 19 /// <returns></returns> 20 public static string Send(string mobile, string content, string sign = null) 21 { 22 //發信內容要做一下Url編碼 23 content = HttpUtility.UrlEncode(content + sign); 24 25 var regPhone = new Regex("^[0-9]+[-]?[0-9]+[-]?[0-9]$"); 26 27 if (regPhone.IsMatch(mobile) && !string.IsNullOrEmpty(content)) 28 { 29 string postString = "account={0}&pswd={1}&mobile={2}&msg={3}&needstatus=true&product={4}&extno={5}".FormatMe(Account, Pswd, mobile, content, null, sign); 30 31 var hh = new HttpExtend(); 32 33 var result = hh.PostWebRequest(ServerAddress, postString); 34 35 var returnResult = result.Split(‘,‘)[1].Split(‘\n‘)[0]; 36 if (returnResult != "0") 37 { 38 Log.Error("簡訊網關發生錯誤 錯誤碼{0},MobilePhone{1}".FormatMe(result, "******" + mobile.Substring(6))); 39 } 40 41 ////* 42 //如果returnResult值等於0,表示發送成功 43 44 //發送返回參數說明: 45 //傳回碼 代碼說明 46 //0 提交成功 47 //101 無此使用者 48 //102 密碼錯 49 //103 提交過快(提交速度超過流速限制) 50 //104 系統忙(因平台側原因,暫時無法處理提交的簡訊) 51 //105 敏感簡訊(簡訊內容包含敏感詞) 52 //106 訊息長度錯(> 536或 <= 0) 53 //107 包含錯誤的手機號碼 54 //108 手機號碼個數錯(群發 > 50000或 <= 0; 單發 > 200或 <= 0) 55 //109 無發送額度(該使用者可用簡訊數已使用完) 56 //110 不在發送時間內 57 //111 超出該賬戶當月發送額度限制 58 //112 無此產品,使用者沒有訂購該產品 59 //113 extno格式錯(非數字或者長度不對) 60 //115 自動審核駁回 61 //116 簽名不合法,未帶簽名(使用者必須帶簽名的前提下) 62 //117 IP地址認證錯,請求調用的IP地址不是系統登記的IP地址 63 //118 使用者沒有相應的發送許可權 64 //119 使用者已到期 65 //120 測試內容不是白名單 66 67 return returnResult; 68 } 69 else 70 { 71 return "103"; 72 } 73 } 74 75 /// <summary> 簡訊群發,號碼間用英文逗號分隔 76 /// </summary> 77 /// <param name="mobiles">例如:"15189799192,15189799192"</param> 78 /// <param name="content">群發簡訊內容</param> 79 /// <returns></returns> 80 public static string GroupSend(string mobiles, string content) 81 { 82 //發信內容要做一下Url編碼 83 content = HttpUtility.UrlEncode(content); 84 string result = string.Empty; 85 if (!string.IsNullOrEmpty(content)) 86 { 87 var postString = "account={0}&pswd={1}&mobile={2}&msg={3}&needstatus=true&product={4}&extno={5}".FormatMe(Account, Pswd, mobiles, content, null, null); 88 var hh = new HttpExtend(); 89 90 result = hh.PostWebRequest(ServerAddress, postString); 91 92 //* 93 //如果returnResult值等於0,表示發送成功 94 95 //發送返回參數說明: 96 //傳回碼 代碼說明 97 //0 提交成功 98 //101 無此使用者 99 //102 密碼錯100 //103 提交過快(提交速度超過流速限制)101 //104 系統忙(因平台側原因,暫時無法處理提交的簡訊)102 //105 敏感簡訊(簡訊內容包含敏感詞)103 //106 訊息長度錯(> 536或 <= 0)104 //107 包含錯誤的手機號碼105 //108 手機號碼個數錯(群發 > 50000或 <= 0; 單發 > 200或 <= 0)106 //109 無發送額度(該使用者可用簡訊數已使用完)107 //110 不在發送時間內108 //111 超出該賬戶當月發送額度限制109 //112 無此產品,使用者沒有訂購該產品110 //113 extno格式錯(非數字或者長度不對)111 //115 自動審核駁回112 //116 簽名不合法,未帶簽名(使用者必須帶簽名的前提下)113 //117 IP地址認證錯,請求調用的IP地址不是系統登記的IP地址114 //118 使用者沒有相應的發送許可權115 //119 使用者已到期116 //120 測試內容不是白名單117 }118 return result;119 }120 }
手機傳送簡訊