Development example for SMS interface

Source: Internet
Author: User

1. Development background

The premise has the message gateway's credentials, and the information is valid. Self-Purchase, this example to "wave" business SMS Express for example.

Now encountered a lot of situations are to use the function of the message sent, such as: User registration to obtain verification code, platform to the user to push information, etc., its implementation principle is roughly the same, no complex logic needs to understand, only need to be familiar with the SMS gateway or the corresponding rules of the mail gateway.

2. Java Development Example

A) The account information of the SMS gateway is stored in the form of a configuration file, each time a call is made, and the account information is obtained by invoking the encrypted configuration file.

b) In the form of an interface to define the function of sending text messages a lot of benefits: for example, the function of sending SMS in the project is to call this interface, then the next time to change the message Gateway, program interface and other places do not need to move, only need to modify the interface implementation class;

c) Call the SMS interface is specific to the requirements. For example, the demand here is to send a passive text message, which is triggered after the send, do not need to do a persistent operation.

SMS Interface Definition: Surf Business Express SMS Web interface document

3, Wave SMS interface notes:

a) interface encoding is GB2312 if the mobile phone received text message is garbled can do the text message content UrlEncode Coding

b) Log in, send text messages, maintain heartbeat, log off; the entire process must be completed in one session, otherwise you will not be able to log in, cannot log off or other exceptions, then you need to contact customer service to manually remove the logon log

c) If you do a persistent operation: Heartbeat connection recommended 50 seconds-2 minutes to do once if there is an abnormal fall off the line is not normal logoff will be dropped after 5-15 minutes (if not write IE cache), so it is recommended that 5 minutes to re-attach a frequent connection when the malicious connections processing

d) It is recommended that you do not write the IE cache because there is an abnormal fall out of the situation without the normal logoff of the case of re-connection may be a long time to return 1000 error (the current user is logged in)

e) recommended to send SMS interval 0.1 seconds to submit once, bulk one time to submit up to 1000 mobile phone number

f) Passwords need special encryption to use, encryption tools see attachments.

4. Code Map

A) account configuration file

b) Interface

c) Implementation class




Note: The above code map is a common implementation method, no need to log in, direct call method to send; to persist, you need to do the following:




The most important step is to:

Because a series of persisted operations is to be done in the same session, each HTTP request will generate a different SessionID setting just that step so that the SessionID is the same not set is the system default.

Last complete an error code number:2008 because the inscription is not added or the inscription is incorrect

Development example for SMS interface

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.