ASP. net mvc Alibaba is better than short message interface development SMS group function, mvc Alibaba

Source: Internet
Author: User

ASP. net mvc Alibaba is better than short message interface development SMS group function, mvc Alibaba

Many companies on the internet provide short message interface services, such as Netease cloud mail and Alibaba Cloud account. In my own project, I need to use the SMS service for notification. The actual development cycle is three days and configuration, development, and usage are completed. In general, the interfaces provided by Alibaba Cloud are easy to develop, it is very convenient. The SMS fee is calculated and paid. As a personal developer, the service I use will incur 0.045 RMB/entry (less than 0.1 million entries ).

Now we need to implement the function of sending group notifications in a regular meeting. All the notification object information is stored in Mysql, and the application architecture is asp.net MVC. First, prepare the obtained API items (the following service parameters must be applied for later than the official website ),

Apply for your own text message signature and text message template. These parameters are required by the service provider:

ITopClient client = new DefaultTopClient (url, appkey, secret); AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest (); req. extend = ""; // can be empty. The returned status is req. smsType = "normal"; // req cannot be changed. smsFreeSignName = ""; // The text message signature applied for. You cannot enter a req different from the applied text message. smsParam = ""; // the variables in the SMS template include: {name} req. recNum = "13000000000"; // phone number req. smsTemplateCode = ""; // ID of the SMS template. Error: AlibabaAliqinFcSmsNumSendResponse rsp = client. execute (req); Console. writeLine (rsp. body );

During specific development, you need to note that this code is an official sample. When writing a text message sending method, paste it for development. Template variable pairing is particularly important:

Req. SmsParam = ""; // the variables in the SMS template include: {name}

In this case, the basic functions of String concatenation are required. Because it is json-like

Req. SmsParam = "{number: '" + Password + "'}"; // remove the double quotation mark {number: 'Password '}

After finishing the details, start to reference the compiled dll in the project on the local machine. The dll file can be larger than the official website of Alibaba,

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"; // req cannot be changed by default to normal. smsFreeSignName = ""; // req is required for text message signatures. smsParam = "{number: '" + Password + "'}"; // req is required for parameters in the template. recNum = phonenum; // req is required for the mobile phone number. smsTemplateCode = "SMS _ *******"; // AlibabaAliqinFcSmsNumSendResponse rsp = client cannot be modified. execute (req );}

This method is developed for the Administrator to retrieve the Password. Note that the input parameters phonenum and Password should be called out from the database before being passed in. It cannot be blank.

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

Here, two URLs are provided on the official website. I prefer https, which makes data transmission safer. For more information, see Alibaba Cloud document.

AlibabaAliqinFcSmsNumSendResponse rsp = client. Execute (req );

// After the object is instantiated, this is the last step in calling the api sending method. Before that, each item must be correct. If an error occurs, you can use Console. WriteLine (rsp. Body );

// Error message displayed

For how to implement the group function, write a SendSmsForMeetingTime (string name, string time, string phonenum, string department, string minister) method function. I used the List <Model>, read multiple pieces of data from the database into the List. Use foreach (var item in list) to call SendSmsForMeetingTime each time during traversal. When the traversal is complete, each notification object is passed in to the method parameter. After the method is executed, the call is implemented.

Here, we will describe the process of calling the interface and passing the text message. User client/user server --> Alibaba greater than server --> mobile/telecom/Unicom carrier server --> the object can accept the short message service terminal. In fact, Alibaba is more than the operator's interface that is also called, But Alibaba is more than encapsulating the interface to cheap development. On this basis, our developers can complete third-party interface development, these developers only limit the APIS encapsulated by the service provider. Developers cannot call APIs not encapsulated by the service provider.

The above is my instance experience in calling APIs in the actual project. The project has also undergone user usage tests and is currently unavailable. This also shows that Alibaba is greater than in the text message interface service, the efficiency of information transmission is still the conscience of the industry.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.