1 Public classPhone2 {3 /// <summary>4 ///Log5 /// </summary>6 Public Static ReadOnlyILog Log =Logmanager.getlogger (Methodbase.getcurrentmethod (). DeclaringType);7 8 9 Public Static ReadOnly stringServerAddress = configurationmanager.appsettings["phoneserveraddress"];Ten Public Static ReadOnly stringaccount = configurationmanager.appsettings["Phoneusername"]; One Public Static ReadOnly stringPSWD = configurationmanager.appsettings["Phonepassword"]; A - /// <summary> - ///send SMS to your phone the /// </summary> - /// <param name= "mobile" >Phone number</param> - /// <param name= "Content" >content</param> - /// <param name= "sign" >Signature</param> + /// <returns></returns> - Public Static stringSend (stringMobilestringContentstringSign =NULL) + { A //Send content to do the URL encoding atContent = Httputility.urlencode (content +Sign ); - - varRegphone =NewRegex ("^[0-9]+[-]? [0-9]+[-]? [0-9]$"); - - if(Regphone.ismatch (MOBILE) &&!string. IsNullOrEmpty (content)) - { in stringPoststring ="account={0}&pswd={1}&mobile={2}&msg={3}&needstatus=true&product={4}&extno={5}". Formatme (account, PSWD, mobile, content,NULL, sign); - to varHH =Newhttpextend (); + - varresult =HH. Postwebrequest (serveraddress, poststring); the * varReturnresult = result. Split (',')[1]. Split ('\ n')[0]; $ if(Returnresult! ="0")Panax Notoginseng { -Log.error ("SMS Gateway Error error code {0},MOBILEPHONE{1}". Formatme (Result,"******"+ Mobile. Substring (6))); the } + A ////* the //if the Returnresult value equals 0, the send succeeds + - //Send return parameter description: $ //return Code Code description $ //0 Successful Submission - //101 No This user - //102 Wrong Password the //103 Commit too fast (submit faster than flow limit) - //104 System Busy (due to platform-side reasons, temporarily unable to process the submitted SMS)Wuyi //105 Sensitive text messages (SMS content contains sensitive words) the //106 Message Length error (> 536 or <= 0) - //107 contains the wrong phone number Wu //108 Wrong number of mobile phone number (Mass > 50000 or <= 0; single > 200 or <= 0) - //109 No Send quota (the number of messages available for this user has been exhausted) About //110 Not in Send time $ //111 exceeding the current month limit for the amount of the account sent - //112 No This product, the user did not order the product - //113 Extno Format error (not number or length) - //115 Automatic audit rejection A //116 signature is not valid, unsigned (the user must have signed the premise) + //117 IP Address authentication error, the IP address of the request call is not the system registered IP address the //118 users do not have the appropriate send permissions - //119 user has expired $ //120 test content is not a whitelist the the returnReturnresult; the } the Else - { in return "103"; the } the } About the /// <summary>mass SMS, separated by commas between numbers the /// </summary> the /// <param name= "mobiles" >For example: "15189799192,15189799192"</param> + /// <param name= "Content" >Mass SMS Content</param> - /// <returns></returns> the Public Static stringGroupsend (stringMobiles,stringcontent)Bayi { the //Send content to do the URL encoding theContent =Httputility.urlencode (content); - stringresult =string. Empty; - if(!string. IsNullOrEmpty (content)) the { the varPoststring ="account={0}&pswd={1}&mobile={2}&msg={3}&needstatus=true&product={4}&extno={5}". Formatme (account, pswd, mobiles, content,NULL,NULL); the varHH =Newhttpextend (); the -result =HH. Postwebrequest (serveraddress, poststring); the the //* the //if the Returnresult value equals 0, the send succeeds94 the //Send return parameter description: the //return Code Code description the //0 Successful Submission98 //101 No This user About //102 Wrong Password - //103 Commit too fast (submit faster than flow limit)101 //104 System Busy (due to platform-side reasons, temporarily unable to process the submitted SMS)102 //105 Sensitive text messages (SMS content contains sensitive words)103 //106 Message Length error (> 536 or <= 0)104 //107 contains the wrong phone number the //108 Wrong number of mobile phone number (Mass > 50000 or <= 0; single > 200 or <= 0)106 //109 No Send quota (the number of messages available for this user has been exhausted)107 //110 Not in Send time108 //111 exceeding the current month limit for the amount of the account sent109 //112 No This product, the user did not order the product the //113 Extno Format error (not number or length)111 //115 Automatic audit rejection the //116 signature is not valid, unsigned (the user must have signed the premise)113 //117 IP Address authentication error, the IP address of the request call is not the system registered IP address the //118 users do not have the appropriate send permissions the //119 user has expired the //120 test content is not a whitelist117 }118 returnresult;119 } -}
Send SMS by mobile phone