asp.net mvc ali more than SMS interface development of Bulk SMS can _ practical skills

Source: Internet
Author: User
Tags extend

There are many companies on the Internet to provide 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 inform the function, the actual development cycle of three days, the completion of configuration, development and use, the general said, Ali is greater than the provision of the interface easy to develop, very convenient, SMS fees are counted to pay, as a personal developer, I use the service business generated by the cost of 0.045¥/ (less than 100,000 articles).

Now to implement a regular SMS mass notification function, all the notified object information is stored in MySQL, application architecture using ASP.net MVC. First ready to get the API items (the following service parameters are required to apply on a larger than the official web),

Apply for their own short message 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";//req cannot be changed
. Smsfreesignname = "" "//The application of the short message signature, can not be filled out with the application of the
req. Smsparam = "";//SMS template variables such as: {name}
req. Recnum = "13000000000";//Mobile number
req. Smstemplatecode = "";//SMS template number, not error
alibabaaliqinfcsmsnumsendresponse RSP = client. Execute (req);
Console.WriteLine (RSP. body); 

In the specific development, it is necessary to note that this section of code is the official sample, in the letter sent to write the method, it will be pasted and then developed. The pairing of template variables is particularly critical:

Req. Smsparam = "";//SMS template variables such as: {name}

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

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

After finishing the details, start referencing the compiled DLL in the project on this machine, which can download the zip compression package in Ali larger than the official website https://www.alidayu.com/center/application/sdk . Unpack to get the generated DLL. Then write a void method that can send text messages,

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 change
 req. Smsfreesignname = "Courtyard Red will net Xuan";//SMS signature must fill in
 req. Smsparam = "{number: '" + Password + "'}";//template parameters must be filled in
 req. Recnum = phonenum;//Mobile phone number must be filled
 req. Smstemplatecode = "sms_******";//Cannot change
 alibabaaliqinfcsmsnumsendresponse RSP = client. Execute (req);
 }

This method is I for the administrator to retrieve the password developed, which need to pay attention to, the incoming parameter Phonenum,password, before passing in from the database, must not be empty.

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

There are two of these URLs in the official list, and I prefer HTTPS so the data is more secure. Please refer to the specific choice of Ali more than the official website document.

Alibabaaliqinfcsmsnumsendresponse RSP = client. Execute (req);

After this object is instantiated, it is the last step in the API to send method calls, before which each item is correct, and error can be Console.WriteLine (RSP). body);

Displays an 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 use the LIST<MODEL>, read multiple data in the database into the list, use foreach (var item in list), call once sendsmsformeetingtime in every traversal, and when the traversal completes, The information for each notification object is passed into the method parameter, and the call is implemented after the method has been executed.

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 larger than the operator's interface, but Ali is more than the interface to the Low-cost development, and we developers on this basis to complete Third-party interface development, these developments are limited to the service provider to encapsulate which interfaces, developers can not invoke the service provider's not packaged interface.

The above is I in the actual project Invoke API instance experience, the project also experienced the user's use test, the present condition, this also explained that the Ali is bigger than in the short message interface service This piece, the information conveys the efficiency or the industry conscience.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.