SMS interface Call--Ali greater than API development experience

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.45¥/ 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:

1Itopclient client =Newdefaulttopclient (URL, Appkey, secret);2Alibabaaliqinfcsmsnumsendrequest req =Newalibabaaliqinfcsmsnumsendrequest ();3Req. Extend ="";//nullable, return status4Req. Smstype ="Normal";//cannot be changed5Req. Smsfreesignname ="";//The application of the text message signature, can not be filled with the application of the6Req. Smsparam ="";//the variables in the SMS template are as follows: {name}7Req. Recnum ="13000000000";//Mobile phone number8Req. Smstemplatecode ="";//SMS template number, not error9Alibabaaliqinfcsmsnumsendresponse RSP =client. Execute (req);TenConsole.WriteLine (RSP. Body);
View Code

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 =  ""  ;//短信模板中的变量如:{name}in this case, the string concatenation to have the basic skills, because the class is JSON, soreq. 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,
1  Public voidSmssendforfindpassword (stringPhonenum,stringPassword)2         {3             stringURL ="https://eco.taobao.com/router/rest";4             stringAppkey ="********";5             stringSecret ="**********************"; 6Itopclient client =Newdefaulttopclient (URL, Appkey, secret);7Alibabaaliqinfcsmsnumsendrequest req =Newalibabaaliqinfcsmsnumsendrequest ();8Req. Extend ="";9Req. Smstype ="Normal";//default normal cannot be changedTenReq. Smsfreesignname ="Hospital Red Council network Xuan";//SMS Signature Required OneReq. Smsparam ="{number: '"+ Password +"'}";//parameters in the template must be filled AReq. Recnum = Phonenum;//mobile phone number must be filled -Req. Smstemplatecode ="sms_******";//cannot be changed -Alibabaaliqinfcsmsnumsendresponse RSP =client. Execute (req); the}
View Code
    • 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), where the URL is given in the official two, I prefer HTTPS, so that the data transfer is more secure. Please refer to Ali more than the official documents.
    • Alibabaaliqinfcsmsnumsendresponse RSP = client. Execute (req);//After the 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);//Display 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 used LIST<MODEL> to read multiple data in the database into the list, using a foreach (var item in list), A sendsmsformeetingtime is called 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 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 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.

SMS interface Call--Ali greater than API development experience

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.