C#_ Send SMS to mobile phone

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:

            Try            {                stringURL ="http://utf8.sms.webchinese.cn/?"; stringStruid ="uid="; stringStrkey ="&key=xx";//here * represents the secret key, because from the long a bit of trouble, it does not enter the window 3fc6f3e0531b7e9aec9e                stringStrmob ="&smsmob="; stringStrcontent ="&smstext="; string_url = URL + struid +"xx"+ strkey + Strmob +"xx"+ Strcontent +"B, B, B? b is there a no? How are you, bear? What are you doing? Savatika "; stringResult =Gethtmlfromurl (_url);                Response.Write (Result); //mailsend.sendmail ("aaaaaa", "aaaaaaaaaaa", "[email protected]");            }            Catch(Exception ex) {Response.Write (ex).            Message); }
Code
   Public stringGethtmlfromurl (stringURL) {            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; }
Code

Tip: When HTTP calls the URL interface, the parameter value must be URL-encoded before calling

parameter Variables Description
GBK encoded URL http://gbk.sms.webchinese.cn/
UTF-8 encoded URL http://utf8.sms.webchinese.cn/
Uid The user name of the site (if you do not have this site user name please register) [FREE registration]
Key Registration of the interface key (can be changed to the user platform to modify the interface key) [Edit immediately]
If you need to encrypt the parameter, change the key variable name to KeyMD5,
Keymd5= interface key 32-bit MD5 encrypted, uppercase.
Smsmob Purpose mobile phone number (multiple mobile phone number, please use a comma separated by commas)
Smstext SMS content, up to 300 words, ordinary SMS 70 words/bar, long and short letter 64 words/bar Billing

Multiple phone numbers, please use half-width, separate

GBK encoded Send interface address :
http://gbk.sms.webchinese.cn/?Uid= site user name &key= interface security Password &smsmob= mobile phone number &smstext= SMS content
UTF-8 encoded Send interface address:
http://utf8.sms.webchinese.cn/?Uid= site user name &key= interface security Password &smsmob= mobile phone number &smstext= SMS content
Get SMS Number Interface address (UTF8):
http://sms.webchinese.cn/web_api/SMS/?Action=SMS_Num&Uid= site user name &key= interface security Password
Get SMS Number Interface address (GBK):
http://sms.webchinese.cn/web_api/SMS/GBK/?Action=SMS_Num&Uid= site user name &key= interface security Password

C#_ Send SMS to mobile phone

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.