ASP. NET MVC Ali larger than SMS interface development SMS Bulk can

Source: Internet
Author: User
There are many companies on the Internet providing SMS interface services, such as NetEase cloud letter, Ali greater than and so on. I need to use the SMS service in my project to notify the role, the actual development cycle of three days, complete the configuration, development and use, the total said, Ali is more than the interface provided easy to develop, very convenient, SMS charges are counted to pay, as a personal developer, I use the services generated by the cost of 0.045¥/ Strips (below 100,000).

Now to achieve a regular message mass notification function, all the notified object information is stored in MySQL, the application architecture using ASP. First prepare to obtain the API items (the following service parameters need to be greater than the official online application),

Apply for your own SMS signature and SMS template, according to the requirements of the service providers need these parameters:

Itopclient client = new Defaulttopclient (URL, Appkey, secret); Alibabaaliqinfcsmsnumsendrequest req = new Alibabaaliqinfcsmsnumsendrequest (); req. Extend = "";//nullable, return status req. Smstype = "normal";//Cannot change req. Smsfreesignname = "";//Application of the SMS signature, can not be filled with the application of the Req. Smsparam = "";//A variable in a text message template such as: {Name}req. Recnum = "13000000000";//Mobile phone number req. Smstemplatecode = "";//SMS template number, not error alibabaaliqinfcsmsnumsendresponse RSP = client. Execute (req); Console.WriteLine (RSP. Body);

In the specific development, it should be noted that this piece of code is an official sample, in the text message sending method, paste it and then develop. The pairing of template variables is particularly critical:

Req. Smsparam = "";//A variable in a text message template such as: {name}

In this case, the string concatenation to have the basic skills, because the class is JSON, so

Req. Smsparam = "{number: '" + Password + "'}";//minus double quotes is {number: ' Password '}

After the details, began to reference the compiled DLL in the project on this machine, the DLL file can be in Ali more than the official website https://www.alidayu.com/center/application/sdk Download zip compression package, Unzip to get the generated DLL. Then write a void method that can send a text message,

public void Smssendforfindpassword (string phonenum,string Password) {string url = "Https://eco.taobao.com/router/rest" ; String appkey = "********"; String secret = "**********************"; Itopclient client = new Defaulttopclient (URL, Appkey, secret); Alibabaaliqinfcsmsnumsendrequest req = new Alibabaaliqinfcsmsnumsendrequest (); Req. Extend = ""; Req. Smstype = "normal";//default normal cannot be changed req. Smsfreesignname = "Hospital Red will network Xuan";//SMS signature must be filled req. Smsparam = "{number: '" + Password + "'}";//template parameters must be filled in req. Recnum = phonenum;//Mobile phone number is required req. Smstemplatecode = "sms_******";//cannot be modified alibabaaliqinfcsmsnumsendresponse RSP = client. Execute (req); }

This method is I for the administrator to retrieve the password development, which need to note that the incoming parameter Phonenum,password, before the incoming from the database recall, not empty.

Itopclient client = new Defaulttopclient (URL, Appkey, secret);

This one of the URLs in the official gave two, I prefer HTTPS, so that data transfer more secure. Please refer to Ali more than the official documents.

Alibabaaliqinfcsmsnumsendresponse RSP = client. Execute (req);

Once this object is instantiated, it is the last step of the API Send method call, before which each item is correct and an error can be used with Console.WriteLine (RSP). Body);

Show error message

For how to implement the mass function, write a sendsmsformeetingtime (string name, string time, String phonenum, String department, String minister) method function , I used List<model>, read multiple data in the database into list, use foreach (var item in list), call once sendsmsformeetingtime in each traversal, and when the traversal is complete, The information for each notification object is passed into the method parameter, and the call is implemented after the method has finished executing.

Here is a description of the interface call, the flow of text messages. User Client/user server--Ali is larger than server--Mobile/Telecom/Unicom operator Server--object can accept SMS service terminal. In fact, Ali is more than the interface of the calling operator, but Ali is more than the encapsulation of the interface to cheap development, and our developers on this basis to complete the development of third-party interface, these development is limited to the service provider encapsulates which interfaces, developers can not call the service provider unpackaged interface.

The above is I in the actual project call API instance experience, the project also experienced the user's use test, currently not out of the situation, which also shows that Ali more than in the SMS Interface service this piece, the efficiency of information transmission or the industry conscience.

The above is the whole content of this article, I hope that everyone's learning has helped, but also hope that we support topic.alibabacloud.com.


Related Article

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.