SMS Server Api
SMS Server Api
SMS Server Api
SMS Server v1.27 or above supports a highly efficient interface with a third party SMS
platform. A typical network topology diagram is shown below.
Post syntax:
Post http://<IP>/goip/<command/
Notes:
1. 【 "auth":{"username":"login name","password":"login password"} 】, any request must
accompanied with the login name and password. If the login information is not
provided, the SMS server will return an error message 401.
2. <command> refers to the port that is providing different functions.
sendsms, Sending SMS
querysms, Query SMS transmit status
querylines, Query the status of all lines in the GoIP
3. At the end of a URL request, “/”character cannot be omitted.
4. All characters MUST be encoded in UTF-8 format.
2 Sending SMS
2.1 Send a SMS Request
Command:sendsms
Json Parameters:
Name Description
auth Mandatory, Authentication information must be provided.
provider Optional,Specify the Carrier name of a GoIP line.
goip_line Optional,Specify which GoIP line is going to be used to send
SMS.
number Mandatory,Specify the recipient numbers (separated by “,”
and the max. is 9999)
content Mandatory,The SMS content to be sent.
Example:
Using a China Mobile line to send out a SMS to the number 13600000000, 13611111111,
13622222222. The SMS content is “Testing”.
Syntax:
POST http://<IP>/goip/sendsms/
{
"auth":{"username":"login name","password":"login password"},
"provider":"China Mobile",
"number":"13600000000,13611111111,13622222222",
"content":"Testing"
}
Notes:
1. Providers are defined in the in the SMS Server as shown below.
These names can be the actual provider names or names that are created for
classification purpose.
2. goip_line and provider are optional.
If provider is specified, then a line that belongs to the provider will be used for sending SMS.
A line will be reused based on the round robin method.
If goip_line is specified,then the specified line will be used.
If both provider and goip line are specified, then goip line has priority over provider. This
means provider will be ignored.
If both provider and goip line are not specified, then all the line selection is based on the
algorithm described in 4 below.
3. If the same number is repeated in a request, then they will be treated as one number
only.
4. Line reusing algorithm: Round robin algorithm is employed. Initially, all lines within the
group are put in a circular buffer. If goip line is specified, then the corresponding line
is taken out from the buffer directly to send the SMS. Once the SMS is sent, it will then
put to the end of the circular buffer. Otherwise, a line is taken out from the start of the
buffer to send the SMS and put to the end afterward.
{“result”:“ACCEPT”,“taskID”:”<ID>”}
Or
{“result”:”REJECT”,”reason”:”<content>}
Name Description
Examples:
{"result":"ACCEPT","taskID":"5689"}
{"result":"REJECT","reason":"none_line"}
Note:
A send SMS request may contain up to 9999 recipient numbers. This means up to 999
SMS may have to be sent. For each send request, a “taskID”is generated and a sub ID is
generated for each recipient number. Therefore, each individual SMS can then be queried with
the reference number syntax as <task ID>.<number>.
For example, if the task ID generated is 5689 and the recipient number is 13600000000,
then unique reference number for the SMS is 5689.13600000000. Please see section 3.1 for
more information.
When sending a SMS is completed, the SMS server immediately sends out a status report
via http with the following Json data.
{“taskID”:<ID>,””goip_line”:”<line name>”,”send”:”<status>”,”<otherparameter>”:”<value>”}
Json Parameters:
Name Description
taskID This is the task ID including the recipient number. It identifies the
SMS task is originated from which send request and the recipient
number.
Example:3578.13612345678
goip_line This identifies which GoIP line actually sent out the SMS.
send SMS Status:
succeeded – Sent completed
failed – Sent failed
unsend – SMS not sent yet
sending – Sending SMS in progress
receipt This indicate if there is a response from the recipient or not. When
a response is received from the recipient, then send ”receipt = 1”
err_code This indicates the error code when sending the SMS failed. Please
refer to 《Appendix A CMS ERROR》 for more information.
Examples:
1. Sending SMS failed:
Json data:
{"taskID":"5689.13600000000","goip_line":"G101","send":"failed","err_code":"350"}
3. Sending SMS succeed and a response is also received from the recipient.
Json data:
{"taskID":"5689.13600000000","goip_line":"G101","send":"succeeded","receipt":"1"}
Note:
SMS Server will not report status of those not able to send and those are sending in
progress. They will be reported only upon receiving a “querysms” request.
Syntax:
POST http://<IP>/goip/querysms/
{
"auth":{"username":"login name ","password":”login passwod"},
"taskID":"5689"
}
Note: taskID is the ID that is responded by the SMS Server after receiving the Send SMS Request.
2. Send a query request on a specific SMS transmission. The taskID must also include
the recipient number.
Syntax:
POST http://<IP>/goip/querysms/
{
"auth":{"username":"login name","password":"login password"},
"taskID":"5689.13600000000"
}
Example:
Below is an example of a SMS status query response for the taskID 5689 with 4 recipients.
Please note that all recipients are shown if the recipient number is not specified.
[
{"taskID":"5689.13600000000","goip_line":"G101","send":"failed","err_code":"350"},
{"taskID":"5689.13600000001","goip_line":"G102","send":" succeeded "},
{"taskID":"5689.13600000002","goip_line":"null","send":"sending"},
{"taskID":"5689.13600000003","goip_line":"null","send":"unsend"},
]
Notes:
1. If a taskID with a recipient number is specified, only the status json object for that
number is reported in the array.
2. If the taskID specified does not exist, the returned response is an empty array.
Example:
POST http://<ip>/goip/querylines/
{"auth":{"username":"login name","password":"login password"}}
Json Parameters:
Name Description
goip_line GOIP Line ID
online SMS Server Connection status
1 – Connected
0 – Not Connected
reg GOIP SIM Registration Status
LOGIN – SIM registered to cellular
LOGOUT – SIM not registered to cellular
Null – Eqv. to LOGOUT
remain_sms The remaining number of SMS transmissions permitted.
“-1” means that there is no limit.
day_remain_sms The daily remaining number of SMS transmissions
permitted. “-1” means that there is no daily limited.
Examples:
[
{"goip_line":"G101","online":"1","reg":"LOGOUT","remain_sms":"-1","day_remain_sms":"-1"},
{"goip_line":"G102","online":"1","reg":"LOGIN","remain_sms":"856","day_remain_sms":"56"},
{"goip_line":"G103","online":"1","reg":"","remain_sms":"-1","day_remain_sms":"-1"},
{"goip_line":"G104","online":"0","reg":"","remain_sms":"-1","day_remain_sms":"-1"}
]
Note:
The maximum and daily limits per GoIP line are configured in the SMS Server. The
remaining number and the daily remaining number of SMS transmissions are stored in the
parameters “remain_sms” and “day_remain_sms” respectively.
Once a SMS from a GoIP line is received, SMS Server forwards the SMS to the URL specified
by using http POST command. The Json format is shown below.
Json Parameters:
Name Description
goip_line This shows the ID of the GoIP line received the SMS.
from_number This shows the number of the SMS sender.
content SMS content
recv_time Time received and the format is:“YYYY-MM-DD hh:mm:ss”
Example:
{ "goip_line":"G101",
"from_number":"10086",
"content":"Dear Customer: This event has ended. Thank you for your support!",
"recv_time":"2019-09-26 15:26:05"
}
6 Other Interfaces
6.1 Send USSD
Request:
http://sms_server_ip/goip/en/ussd.php?
USERNAME=<username>&
PASSWORD=<password>&
TERMID=<GoIP_Line_ID>&
USSDMSG=<USSD_Command>
Parameters:
USERNAME Login username of SMS SERVER
PASSWORD Login password of SMS SERVER
TERMID GoIP Line ID in SMS SERVER
USSDMSG USSD Command
Example:
http://192.168.2.2/goip/en/ussd.php?USERNAME=root&PASSWORD=root&TERMID=GOI
PTAREK1&USSDMSG=*101#
Notice:
Requires to use URL Encoding for charactors in URL.
For example:
“*” has to be replaced by “%2A”
“#”has to be replaced by “%23”
Refer to: https://www.w3schools.com/tags/ref_urlencode.ASP
Parameters:
USERNAME Login username of SMS SERVER
PASSWORD Login password of SMS SERVER
cmd=DIAL Make a GoIP channel to have a dial test
num The destination number to be dialed
duration duration of the call, unit is seconds
goipname Appoint which GoIP Line to dial
Example:
http://192.168.2.1/goip/api.php?USERNAME=root&PASSWORD=root&cmd=DIAL&num=10086&
duration=30&goipname=G103
Parameters:
USERNAME Login username of SMS SERVER
PASSWORD Login password of SMS SERVER
goipname Appoint which GoIP Line
cmd=callforwading A command to set/query Call-Forwarding
num The destination number to be forwarded
condition 0- Unconditional,
1- Mobile busy,
2- No reply,
3- Not reachable,
4- All Call-Forwarding
switch “enable”or “disable” Call-Forwarding
Examples:
1. enable Unconditional Call-Forwarding
http://192.168.2.1/goip/api.php?USERNAME=root&PASSWORD=root&goipname=G103&cmd=ca
llforwading&switch=enable&num=13612341234&condition=0
2. disable all Call-Forwarding
http://192.168.2.1/goip/api.php?USERNAME=root&PASSWORD=root&goipname=G103&cmd=ca
llforwading&switch=disable&condition=4