Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is ASP.NET MVC Ali larger than SMS interface to develop SMS group sending capacity

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

In this issue, the editor will bring you about what ASP.NET MVC Ali is greater than SMS interface development SMS group. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

There are many companies on the Internet that provide SMS interface services, such as Yiyunxin, Ali greater than and so on. I need to use SMS service in my own project to play a notification role. The actual development cycle is three days to complete the configuration, development and use. Generally speaking, the interface provided by Ali is easy to develop and very convenient, and the SMS fee is counted and paid. As an individual developer, the fee generated by my service business is 0.045 ¥/ (less than 100000).

Now to achieve a regular meeting SMS group notification function, all the notified object information is stored in Mysql, and the application architecture uses asp.net MVC. First of all, prepare the acquired API (all the following service parameters need to be applied on the official website)

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

ITopClient client = new DefaultTopClient (url, appkey, secret); AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest (); req.Extend = ""; / empty, return status req.SmsType = "normal"; / / unchangeable req.SmsFreeSignName = ""; / / SMS signature of the application, which is different from that of the application req.SmsParam = ""; / / variables in the SMS template such as: {name} req.RecNum = "13000000000"; / / Mobile phone number req.SmsTemplateCode = "" / / SMS template number. No error AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute (req); Console.WriteLine (rsp.Body)

In the specific development, it should be noted that this code is an official sample, when writing the SMS sending letter method, paste it and then develop it. The pairing of template variables is particularly critical:

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

In this case, you should have basic skills in string concatenation, because it is jsonized, so

Req.SmsParam = "{number:'" + Password + "'}"; / / remove the double quotation marks and the result is {number:'Password'}

After talking about the details, start to refer to the compiled dll in the project on this machine. The dll file can be downloaded from Ali than the official website https://www.alidayu.com/center/application/sdk, and the generated dll can be obtained by decompressing it. 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 be changed req.SmsFreeSignName =" Institute of Red Society publicity " / / required SMS signature req.SmsParam = "{number:'" + Password + "'}"; / / required parameters in the template req.RecNum = phonenum;// mobile phone number required req.SmsTemplateCode = "SMS_*"; / / unchangeable AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute (req);}

This method is developed by me to retrieve the password for the administrator, and it is important to note that the parameter phonenum,Password, which is called from the database before it is passed in, must not be empty.

ITopClient client = new DefaultTopClient (url, appkey, secret)

Two of these url are officially given, and I prefer https, so that the data transmission is more secure. For specific choices, please refer to Ali greater than the official website documentation.

AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute (req)

/ / after this object is instantiated, it is the last step for api to send method calls. Before that, everything must be correct, and errors can be made using Console.WriteLine (rsp.Body).

/ / an error message is displayed

For how to achieve the mass sending function, write a SendSmsForMeetingTime (string name, string time, string phonenum, string department, string minister) method function, I use List, read multiple pieces of data from the database into List, use foreach (var item in list), call SendSmsForMeetingTime; once in each traversal. When the traversal is completed, the information of each notification object is passed into the method parameters, and after the method is executed, the call is realized.

Explain the process of calling the interface and sending SMS messages here. User client / user server-> Ali greater than server-> Mobile / Telecom / Unicom operator server-> object acceptable SMS service terminal. In fact, Ali is also the calling operator's interface, but Ali greater than encapsulates the interface to cheap development, and we developers can complete the development of third-party interfaces on this basis. These developments are only limited to which interfaces are encapsulated by the service provider. Developers cannot call the interfaces that are not encapsulated by the service provider.

The above is what the editor shares with you: ASP.NET MVC Ali is larger than SMS interface to develop mass SMS sending ability. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report