SMS API (Post Method)
WEB API Description
1 Public
- Get the token and pass it in the header with the key authorization.
- The client must send the form data as POST.
- The server returns json data in a fixed format.
1.1 Login
1.1.1 Getting TOKEN /auth/login
- Create a token, and in other interfaces that require authentication, pass this token value in the header with the key authorization. The validity of the requested token will be automatically extended in the background by 10 minutes each time.
- With the exception of some login-free interfaces, all interfaces should be accessed using the token
Client→Server Request
KEY | VAL | Default | Remark |
username | string | – | Account number (interface must be passed, for verification) |
password | string | – | Password (mandatory for interface, for authentication) md5 encryption is required according to the rule: password + ‘-‘ + account md5(password-username) |
For example.
username:admin
password:32ff9ee7e841b26a966870c144fdcaec
Server→Client Response
KEY | VAL | Default | Remark |
uri | string | – | Returns the name of the URI corresponding to the request |
code | int | – | Success or failure identifier (refer to internationalization.md) |
msg | string | – | Information Alerts |
data | array | – | Data content, as defined by the API function |
access_token | string | – | token, used to request the API. |
expires_time | string | – | The token validity time will be automatically extended by 10 minutes in the background after each request to the interface. |
client | string | – | user information |
For example.
{
"uri": "auth/login",
"msg": "",
"code": 200,
"data": {
"access_token": "Z6Irivg91M6XfE4HFYjRuAwykb3Q4KmW",
"expires_time": 1733131658,
"client": "admin" }}
1.1.2 Logging out /auth/logout
KEY | VAL | Default | Remark |
token | string | – | Token obtained at login |
For example.
token:Z6Irivg91M6XfE4HFYjRuAwykb3Q4KmW
Server→Client Response
{ "uri": "auth/logout", "msg": "Login out success! "msg": "Login out success!", "code": 200, "data": []} "data": []}
2 SMS Management Class
2.1 Sending text messages
2.1.1 Getting ports /sms/get_valid_spans
Get all ports and request an available port to send SMS based on the port state
Client→Server Request
Server→Client Response
DATA_SUBKEY | VAL | Default | Remark |
port | int | Port value (used when sending SMS) | |
port_name | string | port name | |
status | int | Status values. 1: available; 0: not available |
Response.
{ "uri": "sms/get_valid_spans", "msg": "", "code": 200, "data": [ { "port": 1, "port_name": 1, "port_name". "port_name": "gsm-1", "status": 0 } ]}
2.1.2 Send SMS /sms/send
Client→Server Request
KEY | VAL | Default | Remark |
spans[] | array | – | port value |
dest_num | string | – | sender’s number |
msg | string | – | Text message content |
mode | int | 0 | Status values. 0: Asynchronous sending 1: Synchronous sending |
For example.
spans[]:1
dest_num:10086
msg:ye
mode:0
Server→Client Response
KEY | VAL | Default | Remark |
type | string | Status values. 0: Asynchronous sending 1: Synchronous sending | |
msg | string | – | Text message content |
dest_num | string | – | sender’s number |
flash (computing) | string | – | Whether to enable flash |
id | string | – | SMS id |
port | array | – | port value |
For example.
{ "uri": "sms/send", "msg": "", "code": 200, "data": { "send_list": { "type": "asyncsms", "msg": "ye", "num": "10086", "flash": "0", "id": "319162de "id": "319162de-d23a-9f6a-167c-294c9b062f24", "port": "1" }, "reject_list": "" }}
2.2 SMS status
2.2.1 Getting the status of an SMS (outbox) /smsoutbox/get
Client→Server Request
KEY | VAL | Default | Remark |
current_page | int | 1 | Page turn, current page |
current_counts | int | 10 | Number of single page displays |
phone_number_filter | string | – | mobile telephone number |
start_datetime_filter | datetime | – | Start time, format: YY-MM-DD H:i:s |
end_datetime_filter | datetime | – | End time, format: YY-MM-DD H:i:s |
For example.
current_page:1
current_counts:10
phone_number_filter:10086
start_datetime_filter:2024-11-21 09:59:20
end_datetime_filter:2024-11-21 09:59:20
Server→Client Response
DATA_SUBKEY | VAL | Default | Remark |
port_name | string | port name | |
phonenumber | string | mobile telephone number | |
time | datetime | transmission time | |
message | string | Text message content | |
status | string | Status values. There are FAILED, SENT, DELIVERD | |
current_page | int | current page | |
current_counts | int | Number of single page displays | |
counts | int | Total pages |
{ "uri": "smsoutbox/get", "msg": "", "code": 200, "data": { "current_page": 1, "current_counts": 10, "counts": 1, "sms": [ { "port_name": "lte-16", "phonenumber": "10086", "time": "2024-10-28 16:18:22", "status": "DELIVERD(0)", "message": "bj" } ] }}
2.2.2 Getting incoming SMS (inbox) /smsinbox/get
Client→Server Request
KEY | VAL | Default | Remark |
current_page | int | 1 | Page turn, current page |
current_counts | int | 10 | Number of single page displays |
phone_number_filter | string | – | mobile telephone number |
start_datetime_filter | datetime | – | Start time, format: YY/MM/DD H:i:s |
end_datetime_filter | datetime | – | End time, format: YY/MM/DD H:i:s |
flag | string | – | all:get all sms unread:get unread sms read:get read sms |
For example.
current_page:1
current_counts:2
phone_number_filter:1065813919
start_datetime_filter:2023/11/21 09:59:20
end_datetime_filter:2024/11/21 09:59:20
flag:all
Server→Client Response
DATA_SUBKEY | VAL | Default | Remark |
id | string | SMS id | |
port_name | string | port name | |
current_page | int | current page | |
current_counts | int | Number of single page displays | |
counts | int | Total pages | |
phonenumber | string | mobile telephone number | |
time | datetime | transmission time | |
message | string | Text message content | |
read | string | Number of read SMS messages under the current filter | |
unread | string | Number of unread SMS messages in the current filter |
{ "uri": "smsinbox/get", "msg": "", "code": 200, "data": { "read": 10, "unread": 0, "unread": 0 "unread": 0, "current_page": 1, "current_page": 1, "counts": 5, "current_counts": 2, "read": 10, "unread": 0, "current_counts": 2, "sms": [ { "port": "16", "id": 13, "port_name": "gsm-16", "phonenumber": "10086", "time": "2024/10/28 16:18:22", "message":"\ufeffEsteemed customer: your local number is 18818591275, belonging to the Global Link brand. For more package details, please click https://dx.10086.cn/3IT2\ufeffFg to download the "China Mobile" APP to inquire. China Mobile]" }, } { "port": "16", "id": 12, { "id": 12, "port_name": "gsm-16", "phonenumber": "1065813919", "time": "2024/10/27 14:34:32", "message":"\ufeff[Guangdong Mobile] September fun bill has arrived https://y.10086.cn/t/kxyTfJ15eGAyu1f\r\n rejected please reply R [China Mobile 1\ufeff39 mailbox]" } ] }}
2.2.3 Get push SMS status settings /smsoutbox/get_config
Client→Server Request
Server→Client Response
DATA_SUBKEY | VAL | Default | Remark |
enable | int | Push switch. 1 On 0 Off | |
reports_enable | int | SMS report switch. 1 On 0 Off | |
results_enable | int | SMS result switch. 1 On 0 Off | |
url_http | string | url_http key name | |
url_host | string | url_host key name | |
url_port | string | url_port key name | |
url_path | string | url_path key name | |
url_from_num | string | url_from_num key name | |
url_to_num | string | url_to_num key name | |
url_portname | string | url_portname key name | |
url_message | string | url_message key name | |
url_time | string | url_time key name | |
url_imsi | string | url_imsi key name | |
url_status | string | url_status key name | |
url_user_defined | string | url custom key name |
{ "uri": "smsoutbox/get_config", "msg": "", "code": 200, "data": { "enable": 1, "reports_enable": 1, "results_enable": 1, "url_http": "http", "url_host": "172.16.2.43", "url_port": "80", "url_path": "test.php", "url_from_num": "phone_number", "url_to_num": "port", "url_portname": "portname", "url_message": "message", "url_time": "time", "url_imsi": "imsi", "url_status": "status", "url_user_defined "url_user_defined": "" }}
2.2.4 Save push SMS status settings /smsoutbox/set_config
Client→Server Request
KEY | VAL | Default | Remark |
References/smsoutbox/get_config |
For example.
enable:1
reports_enable:1
results_enable:1
url_http:http
url_host":172.16.2.43
url_port:80
url_path:test.php
url_from_num":phonenumber
url_to_num:port
url_portname:portname
url_message:message
url_time:time
url_imsi:imsi
url_status:status
url_user_defined:id=id
Server→Client Response
{ "uri": "smsoutbox/set_config", "msg": "", "code": 200, "data": []}
3 Service category
3.1 Obtaining status
3.1.1 Getting the channel state /service/chan_state
Client→Server Request
Server→Client Response
DATA_SUBKEY | VAL | Default | Remark |
idle_channels | string | Total Idle Channels | |
channel_status | string | Channel status; left column indicates channel number; right column: 1 indicates unregistered; 0 indicates registered |
{ "uri": "service/chan_state", "msg": "", "code": 200, "data": { "idle_channels": 0, "channel_status": { "1": "1", "2": "1", ..." 32": "1" } }}
3.1.2 Get SIM status and IMSI number. /service/simstatus
Client→Server Request
KEY | VAL | Default | Remark |
port | int | 1 | Port number; 0 to get all port status; greater than 0 to get specified port status |
For example.
port:0
Server→Client Response
DATA_SUBKEY | VAL | Default | Remark |
key | string | port number | |
imsi | string | IMSI number | |
status | string | SIM card status |
{ "uri": "service/simstatus", "msg": "", "code": 200, "data": { "1": { "imsi": "", "status": "Unknown Network Status". "status": "Unknown Network Status" }, "data". "2": { "imsi": "", "status": "Unknown Network Status" }, "2": { "status": "Unknown Network Status" }, ..." 32": { "imsi": "", "status": "Unknown Network Status" },..." 32": { "imsi": "", "status": "Unknown Network Status" },... "status": "Unknown Network Status" } }}
3.2 USSD
3.2.1 Sendussd /service/sendussd
- No token is required, but provide the account password filled in the page.WEB->SMS->USSD
- Return results can be selected on the page json/string/null
- Processing a send request returns the status value sent
Client→Server Request
KEY | VAL | Default | Remark |
username | int | 1 | Authentication of the username is required when sending USSD, configured in the Web GUI |
password | int | 10 | The password needs to be authenticated when sending USSD, configured in the Web GUI |
message | string | – | Contents of the sent USSD |
port | int | – | The card on the channel must be registered. For multiple ports, splicing |
timeout | int | – | Send USSD timeout |
id | int | – | Associate this ID when receiving USSD results |
For example.
username:ussduser
password:ussdpwd
message:*#301
port: 3,4
timeout: 500
id: 1
Server→Client Response
DATA_SUBKEY | VAL | Default | Remark |
message | string | Content of ussd sent | |
report | object | List of Reports | |
port | string | port number | |
time | string | time of sending (e.g. of a message) | |
id | string | Associate this ID when receiving USSD results | |
result | string | Status of sending: sent/not ready/not select/other |
{ "uri": "service/sendussd", "msg": "", "code": 200, "data": { "message": "*#301", "report": { "3": { "port": "3", "time": "2024-05:07:58", { "time": "2024-12-05 07:12:58", "id": "1", "result": "not ready" }, "4": { "port": "4", "time": "2024-05-07:07 "time": "2024-12-05 07:12:58", "id": "1", "result": "not ready" } } }}
{ "uri": "service/sendussd", "msg": "", "code": 200, "data": "message: *#301\n--record 3 start--port: 3\ntime: 2024/ntime "data": "message: *#301\n--record 3 start--port: 3\ntime: 2024-12-05 07:12:26\nid: 1\nresult: not ready\n--record 3 end----record 4 start--port. 4\ntime: 2024-12-05 07:12:26\nid: 1\nresult: not ready\n--record 4 end--"}
3.2.2 Pushing the results returned by the USSD
- This is the ussd to http interface, you need to build your own http/https server to receive the push content.
- Parameter configuration from the page (WEB->SMS->USSD) The name on the http/https server is the same as the name on the Web GUI.
- The device will push the result returned by USSD in GET mode according to the filled parameters, and the server itself will receive the filled parameters to get the
- You can compose a URL by splicing the test data according to the rules, and access the URL to test whether your server receives the parameters normally.
- Push services are network dependent, make sure your device has access to http/https servers.
Client→Server Request
KEY | VAL | Default | Remark |
path | string | – | (Required) Receiving tool and path |
param1 | string | – | (Required) The name of the channel number; by this name the channel number is indicated; for example, configure port |
param2 | string | – | The name of the USSD content; by this name the USSD content is represented; for example, configure message |
param3 | string | – | The name of the time; by this name the USSD receives the time; for example, configure time |
param4 | string | – | The name of the status; by this name the result of sending the SMS status is indicated; for example, configure status |
param5 | string | – | ussd returns the name of the code result; by this name the USSD code result value is indicated, e.g., configuration code |
param6 | string | – | The name of the id; by this name a unique value is indicated, associated with the id at the time of sending. |
UserDefined | string | – | User-defined parameters |
For example.
http://ip:port/path?param1=${port}¶m2=${message}¶m3=${time}¶m4=${status}¶m5=${code}¶m6=${ id}[&{UserDefined}]
web.
domain: http://172.16.2.43
path: receiveussd.php
param1: my_port
param2: my_message
param3: my_time
param4: my_status
param5: my_code
param6: my_id
UserDefined.
URL:
http://172.16.2.43/receiveussd.php?my_port=${port}&my_message=${message}&my_time=${time}&my_status=${status}&my_ code=${code}&my_id=${id}