Simple implementation of sending SMS messages

Source: Internet
Author: User

Accidentally remembered, like writing a computer to the mobile phone to send text messages from the Internet to find three ways: (1) Use the WebService interface to send SMS, this can be sent using the webservice provided by Sina, but need to register; (2) Use text message Mao's way to send text messages, this way should be more commonly used, the premise is the need to buy hardware equipment, this does not consider (3) the use of Chinese network built SMS platform, but, after a few free, it will be charged.

First of all, I use C # to implement the first method, found always wrong, this puzzled, and later from the Internet to find the reason, some say, Sina this function has not been used, I am not very clear, gave up this method,

A third method was subsequently implemented.

The specific implementation is as follows:

1. From the online (http://sms.webchinese.cn/) application account, remember the user name, password will be sent to the phone, this is only the login password. There is also a secret message key, this to get, this is to be used in the back, to write a good signature inside, but also, the specific implementation, to refer to the SMS API downstream interface parameters (http://sms.webchinese.cn/ api.shtml), this page has a variety of language implementation, I use C # implementation, familiar with Java can be used java.

2. Now can be programmed to implement, this is also very simple, reference interface parameters of the C # implementation of the Web page, the following gives my example!

The interface is as follows:

Since the secret key is a bit long, it is not typed here.

The code is as follows:

 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Windows.Forms;         9 using system.net;10 using System.io;11 namespace SendMsgSMS13 {+ public partial class Form1:form15 {16 private string url = "http://utf8.sms.webchinese.cn/?"; + private String struid = "uid="; private string strkey = "&key=*******************"; Here * represents the secret key, due to a bit of trouble from the long, does not enter the window on the private string strmob = "&smsmob="; private string strcontent = "&amp ; smstext= public Form1 () () {InitializeComponent ();}25 + Private Voi D Button1_Click (object sender, EventArgs e) (TxtUerName.Text.ToString (). Trim ()! = "" && txtAttnNum.Text.ToString (). Trim ()! = "" &&txtcontent.text.tostring ()! = null) $ {url = URL + struid + Txtuername.text + strkey + strmob + txtattnnum.text + strcontent + txtcontent.text;31 string Result = G Ethtmlfromurl (URL), MessageBox.Show (Result),}35}36 PNS public string G Ethtmlfromurl (string url) $ {strret = null;40 if (url = = NULL | | | URL. Trim (). ToString () = = "") * strret;43}44 string targeturl = URL. Trim (). ToString (); try46 {HttpWebRequest hr = (HttpWebRequest) webrequest.create (Targ Eturl); useragent = "mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) "; Method = "GET"; Timeout = * 1000;51 WebResponse hs = hr. GetResponse (); Stream sr = hs.  GetResponseStream (); StreamReader ser = new StreamReader (SR, Encoding.default); = Ser.             ReadToEnd (),}56 catch (Exception ex), strret = null;59 }60 return strret;61}62}63}

Simple implementation of sending SMS messages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.