This tool is based on the Chinese network built SMS SMS API for development, the main function is to use the registered number to send SMS to the specified number, this function is mainly used in enterprise marketing.
China Network construction SMS message pass http://www.smschinese.cn/
in the above-mentioned website registered users, the latter to send information, this article mainly introduces the sending of text messages, do not introduce MMS, we first want to get the key and user name of the SMS
2. Write the request code using API excuses
private void Btnsend_click (object sender, EventArgs e) {if (check ()) {string url = "http://utf8.sms.webchinese.cn/?" +
User name
"Uid=" + txtUserName.Text.Trim () +
SMS Key
"&key=" + txtKey.Text.Trim () +
Received SMS number
"&smsmob=" + txtPhone.Text.Trim () +
SMS Content
"&smstext=" + txtcontent. Text.trim () +
Signature file (must be filled, otherwise error)
"" "+ TxtSign.Text.Trim () +" ""; String Result = Gethtmlfromurl (URL);
Displays the sending result showmessage (int. Parse (Result)); }}//Send public string gethtmlfromurl (string url) {string strret = null; if (string.isnullorempty (URL)) {return strret; } string targeturl = URL. Trim (). ToString (); try {HttpWebRequest hr = (HttpWebRequest) webrequest.create (TargetUrl); hr. useragent = "mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) "; hr. Method = "GET"; hr. Timeout = 30 * 60 * 1000; WebResponse hs = hr. GetResponse (); Stream sr = HS. GetResponseStream (); StreamReader ser = new StreamReader (SR, Encoding.default); strret = ser. ReadToEnd (); Ser. Close (); return strret; } catch (Exception ex) {strret = null; RetUrn strret; } }
3. Based on the return info code to OK prompt
private void ShowMessage (int code) { String message = ""; Switch (code) { case-1: message = "no user account"; CASE-2: Message = "The interface key is incorrect [view key] is not an account login password"; break; Case-21:message = "MD5 interface key encryption is incorrect"; break; CASE-3: message = "Insufficient number of SMS"; break; Case-11:message = "The user is disabled"; break; Case-14:message = "Illegal characters appear in SMS Content"; break; CASE-4: Message = "Cell phone number format is incorrect"; break; Case-41:message = "Mobile phone number is empty"; break; case-42:message = "SMS content is empty"; break; case-51:message = "SMS signature format is incorrect interface signature format:" Signature Content ""; break; CASE-6: Message = "IP Limit"; break; } if (Code > 0) { message = "sent successfully" + code + "bar"; } MessageBox.Show (Message, "Send results"); }
Conclusion
- Benefit, mastered the use of the C#API interface of China Network construction SMS Communication
This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )
Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4681563.html
[Tools-007] C # Mobile SMS Send