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

How to use java SMS interface

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "how to use the java SMS interface". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use the java SMS interface" can help you solve your doubts.

SMS sending API 1.1 request address

The request address is the url address requested when the client interface program is called, using the https post interface, and the address is

Https://sh3.ipyy.com/sms.aspx corresponds to UTF-8

Https://sh3.ipyy.com/smsGBK.aspx corresponds to GB2312

Https://sh3.ipyy.com/smsJson.aspx corresponds to UTF-8 (return value is in json format)

Https://sh3.ipyy.com/ensms.ashx corresponds to UTF-8 (encrypted transmission, using json)

Generally speaking, the entry address will not change, and when there is a change, the interface user will be notified.

1.2 Parameter description

Parameter name

Meaning

Description

Userid

Enterprise id

Enterprise ID (not verified)

Account

Send user account number

User account number, by system administrator

Password

Send account password

The password corresponding to the user account

You can use plaintext or all md5 encryption. Md5 is 32-bit uppercase.

For example, after abc123 encryption,

E99A18C428CB38D5F260853678922E03

Mobile

All dialed numbers

The destination number to which the message is sent. Multiple numbers are separated by half-width commas

Content

Send content

The content of the SMS message needs to be encoded by UTF-8, and the submitted content format: content + [signature]. Signature is the name of the company or the name of the company project. Example: your CAPTCHA: 1439 [take off]. [] is the identifier of the signature. Please submit the content test according to the formal format

SendTime

Timing sending time

If it is empty, it means to send immediately. The timing format is 2010-10-24 09:08:10.

Action

Send task command

Set to fixed: send

Extno

Extended subnumber

Please first ask whether the configured channel supports extended subnumbers. If not, please fill in the blanks. Subnumbers can only be numbers and up to 5 digits.

For example:

Https://sh3.ipyy.com/sms.aspx?action=send&userid=&account= account & password= password & mobile=15023239810,13527576163&content= content & sendTime=&extno=

1.3 return value

After receiving the https request sent by the client, the processing result is returned in the form of xml. The format is:

Status-return status value: successful return Success failed return: Faild

Message-related error description

Remainpoint-returns the balance

TaskID-returns the sequence ID of this task

SuccessCounts-number of successful SMS messages: returns the number of successful SMS messages submitted when successful

1.4 Json return value

{"returnstatus": "Success"

"message": "Operation succeeded"

Remainpoint: "- 4"

"taskID": "1504080852350206"

"successCounts": "1"}

Package com.yy.test

Import java.text.SimpleDateFormat

Import java.util.Date

Import org.apache.commons.httpclient.HttpClient

Import org.apache.commons.httpclient.NameValuePair

Import org.apache.commons.httpclient.methods.PostMethod

Import org.json.JSONObject

Import sun.misc.BASE64Encoder

Public class HttpEnsms {

/ * *

* http encryption

* @ param args

, /

Public static void main (String [] args) {

SimpleDateFormat df=new SimpleDateFormat ("MMddHHmmss")

String Stamp = df.format (new Date ())

String password= "123456"

String Secret=MD5.GetMD5Code (password+Stamp) .toUpperCase ()

Try {

JSONObject j=new JSONObject ()

J.put ("UserName", "qq")

J.put ("Stamp", Stamp)

J.put ("Secret", Secret)

J.put ("Moblie", "17721077856"); / / call can assist in docking

J.put ("Text", "your verification code is: 8859 [Hua Xin]")

J.put ("Ext", "")

J.put ("SendTime", "")

/ / get json string

String json=j.toString ()

Byte [] data=json.getBytes ("utf-8")

Byte [] key=password.getBytes ()

/ / get encrypted key

Byte [] nkey=new byte [8]

System.arraycopy (key, 0, nkey, 0, key.length > 8? 8: key.length)

/ / Des encryption, base64 transcoding

String str=new BASE64Encoder () .encode (DesHelper.encrypt (data, nkey)

System.out.println (str)

/ / url coding

/ / str=URLEncoder.encode (str, "utf-8")

/ / send http request

String Url= "http://42.96.205.165/ensms.ashx";

HttpClient client=new HttpClient ()

PostMethod post=new PostMethod (Url)

Post.setRequestHeader ("Content-type", "application/x-www-form-urlencoded;charset=utf-8")

NameValuePair UserId=new NameValuePair ("UserId", "1")

NameValuePair Text64=new NameValuePair ("Text64", str)

Post.setRequestBody (new NameValuePair [] {UserId,Text64})

Int statu=client.executeMethod (post)

System.out.println ("statu=" + statu)

/ / return the result

String result=post.getResponseBodyAsString ()

System.out.println ("result=" + result)

} catch (Exception e) {

/ / TODO Auto-generated catch block

E.printStackTrace ()

}

}

}

After reading this, the article "how to use java SMS Interface" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, 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

Servers

Wechat

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

12
Report