Now many websites are the function of sending text messages, how to realize it. For the personal webmaster, it is relatively cost-effective and simple to use the SMS API interface. How do you do that, the steps are 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. After registration will send 5 text messages, and 3 MMS message send amount.
2. Check the SMS API downstream interface (http://sms.webchinese.cn/api.shtml), and then get the secret key, is actually the encrypted login password. To start tapping the code, the relevant code is as follows:
usingSystem;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Linq;usingSystem.Net;usingSystem.Text;usingsystem.web;namespacey_postsms{ Public classYmethod {Private stringThe_uid ="";//User name Private stringThe_key ="";//interface secret key /// <summary>return UTF-8 encoded send interface address</summary> /// <param name= "Receivephonenumber" >Purpose Mobile Phone number (multiple mobile phone number, please use a comma separated by commas)</param> /// <param name= "receivesms" >SMS content, up to 400 words, ordinary SMS 70 words/bar, long and short letter 64 words/bar billing</param> /// <returns></returns> Public stringGetposturl (stringSmsmob,stringSmstext) { stringPostURL ="http://utf8.sms.webchinese.cn/?Uid="+ The_uid +"&key="+ The_key +"&smsmob="+ Smsmob +"&smstext="+Smstext; returnPostURL; } /// <summary>send SMS, get return value</summary> Public stringPostsmsinfo (stringURL) { //You only need to pass the URL of the spell to the function when you call it. The return value can be judged stringstrret =NULL; if(url = =NULL|| Url. Trim (). ToString () = ="") { returnstrret; } stringTargetUrl =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= -* -* +; WebResponse HS=HR. GetResponse (); Stream SR=HS. GetResponseStream (); StreamReader ser=NewStreamReader (SR, Encoding.default); Strret=ser. ReadToEnd (); } Catch(Exception ex) {strret=NULL; } returnstrret; } /// <summary>Confirm return Information</summary> Public stringGetResult (stringstrret) { intresult =0; Try{result=int. Parse (strret); Switch(Result) { Case-1: Strret="No such user account"; Break; Case-2: Strret="incorrect interface key, not account login password"; Break; Case- +: Strret="MD5 Interface key encryption is incorrect"; Break; Case-3: Strret="insufficient number of SMS messages"; Break; Case- One: Strret="the user is disabled"; Break; Case- -: Strret="illegal characters appear in SMS content"; Break; Case-4: Strret="cell phone number is not formatted correctly"; Break; Case- A: Strret="cell phone number is empty"; Break; Case- the: Strret="SMS content is empty"; Break; Case-Wuyi: Strret="The SMS signature format is incorrect and the interface signature format is: "Signature content""; Break; Case-6: Strret="IP Restrictions"; Break; default: Strret="number of messages sent:"+result; Break; } } Catch(Exception ex) {strret=Ex. Message; } returnstrret; } }}
3. Find online customer service to send permission, fill in the signature, as follows:
Source code:y_postsms.zip
C # Implementation to send SMS messages