Short Message interface call-Alibaba is better than API development experience, Alibaba api

Source: Internet
Author: User

Short Message interface call-Alibaba is better than API development experience, Alibaba api

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 fee of my services is 0.045 RMB/piece (less than 0.1 million messages ).

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 (You must apply for the following service parameters from the official website.),

Apply for your own text message signature and text message templateAccording to the requirements of the service provider:

 

1 ITopClient client = new DefaultTopClient (url, appkey, secret); 2 AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest (); 3 req. extend = ""; // can be empty, return status 4 req. smsType = "normal"; // do not change 5 req. smsFreeSignName = ""; // The text message signature applied for. It cannot be filled in with a different 6 req from the applied text message. smsParam = ""; // the variables in the SMS template include: {name} 7 req. recNum = "13000000000"; // phone number 8 req. smsTemplateCode = ""; // message template number. Error 9 AlibabaAliqinFcSmsNumSendResponse rsp = client. execute (req); 10 Console. writeLine (rsp. body );View Code

 

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 critical.: 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 + "'}"; // after removing the double quotation marks, it is {number: 'Password, Start to reference the compiled dll in the project on the local machine, The dll file can be larger than the official website of Ali, 1 public void SmsSendForFindPassword (string phonenum, string Password) 2 {3 string url = "https://eco.taobao.com/router/rest "; 4 string appkey = "********"; 5 string secret = "*********************"; 6 ITopClient client = new DefaultTopClient (url, appkey, secret); 7 AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest (); 8 req. extend = ""; 9 req. smsType = "normal"; // The default normal value cannot be changed to 10 req. smsFreeSignName = ""; // The text message signature is required for 11 req. smsParam = "{number: '" + Password + "'}"; // 12 req is required for parameters in the template. recNum = phonenum; // the mobile phone number must be 13 req. smsTemplateCode = "SMS _ *******"; // 14 AlibabaAliqinFcSmsNumSendResponse rsp = client cannot be modified. execute (req); 15}View Code
  • 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, it is the last step in calling the api sending method. Before that, each item must be correct. If an error occurs, you can use the Console. writeLine (rsp. body); // the error message is displayed.

  How to Implement the group Function, Write a SendSmsForMeetingTime (string name, string time, string phonenum, string department, string minister) method function. I used 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.

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.