DWG2000 New API Guide
DWG2000 New API Guide
Version
Date
Description
Author
0.1
2014-12-25
First version
Nate
0.2
2015-1-22
Added user_id in
Nate
send_sms request
0.3
2015-3-20
Added DELIVERED
Nate
2015-4-24
1. Changed Send
Sms request
format, each
number could
include a user_id
2. Added an API for
query current
SMS in the
waiting queue.
3. Added a
parameter user_id
in Query SMS
result
Nate
Content
1 Introduction .................................................................................................................................... 6
1.1 Scenarios .............................................................................................................................. 6
1.2 Network Topology............................................................................................................. 6
1.3 Features................................................................................................................................. 6
1.4 Basic Description ............................................................................................................... 7
1.5 Enable API ............................................................................................................................ 7
2. Send SMS ........................................................................................................................................ 8
2.1 Request ................................................................................................................................. 8
2.2Request Parameters ........................................................................................................... 8
2.3 Response Parameter ......................................................................................................... 9
2.4 Example................................................................................................................................. 9
3. Query Send SMS Result ............................................................................................................. 9
3.1 Request ................................................................................................................................. 9
3.2 Request Parameter .......................................................................................................... 10
3.3 Response Parameter ....................................................................................................... 10
3.4 Example............................................................................................................................... 11
4. Query SMS delivery status...................................................................................................... 12
4.1 Request ............................................................................................................................... 12
4.2 Request Parameter .......................................................................................................... 12
4.3 Response Parameter ....................................................................................................... 13
4.4 Example............................................................................................................................... 13
1 Introduction
1.1 Scenarios
1. A SMS server manages a lot of gateway through API. People can send and
receive SMS through this Server.
2. A lightweight SMS Client communicates with gateway through API. People can
use this application to send and receive SMS.
1.3 Features
Batch SMS
2. Send SMS
2.1 Request
POST http://gateway_ip/api/send_sms
2.2Request Parameters
Parameter
Type
Description
Required Parameter
text
String
param
Array
Optional Parameter
port
Array
encoding
String
Type
Description
error_code
Integer
Possible code,
202, Request has been accepted, will process later.
400, Request format is not valid.
413, number over 128 or text over 1500 bytes
500, other error
sms_in_queue
Integer
task_id
Integer
2.4 Example
Request:
curl -d
'{"text":"#param#","port":[2,3],"param":[{"number":"10086","text_
param":["bj"],"user_id":1},{"number":"10086",
"text_param":["ye"],"user_id":2}]} H "Content-Type:
application/json" http://gateway_ip/api/send_sms
Please note that this example didnt include an username and password.
Please include them in your own code.
Response:
{"error_code":202,"sms_in_queue":2,"task_id":2}
Type
Description
Optional Parameter
number
Array
port
Array
time_after
String
time_before
String
user_id
Array
Type
Description
error_code
Integer
Possible code,
200, Request has been processed.
400, Request format is not valid.
413, size of number array over 32
500, other error
result
Array
3.4 Example
Request
Type
Description
Optional Parameter
number
Array
port
Array
time_after
String
time_before
String
Type
Description
error_code
Integer
Possible code,
200, Request has been processed.
400, Request format is not valid.
413, size of number array over 32
500, other error
result
Array
4.4 Example
Request
curl -d '{"number":["12341234"], "port":[1,2,3],
"time_after":"2014-12-12 19:29:19", "time_before":"2014-12-12
Response
{"error_code":200"result":[{"port":0, "number":"12351",
"time":"2014-12-21 12:06:01","ref_id":12, "status_code":0},]}
Type
Description
error_code
Integer
Possible code,
200, Request has been processed.
500: Other error
in_queue
Integer
5.4 Example
Request
http://gateway_ip/api/query_incoming_sms
Response
{"error_code":200,"in_queue":0}
6. Receive SMS
6.1 Request
GET http://gateway_ip/api/query_incoming_sms
Type
Description
Optional Parameter
incoming_sms_id
Integer
flag
String
read SMS
both of unread and read.
Type
Description
error_code
Integer
Possible code,
200, Request has been processed.
500: Other error
sms
Array
incoming_sms_id: ID in gateways
database
Integer
unread
Integer
6.4 Example
Request
http://gateway_ip/api/query_incoming_sms?flag=all
Response
{"error_code":200, "sms":[{"incoming_sms_id":1, "port":2, "number":
"123456789","smsc":"+8613800123456","timestamp":"2014-12-09
17:11:18","text":"This is a test"},],"read":1, "unread":0}
7 Send USSD
7.1 Request
POST http://gateway_ip/api/send_ussd
Type
Description
Required Parameter
text
String
port
Array
Optional Parameter
command
String
Type
Description
error_code
Integer
Possible code,
202, Request has been accepted.
400, lack of text while command is "send" .
500, other error
result
Array
7.6 Example
Request
curl -d '{"port":[1,2,3],"command":"send","text":"*125#"}' -H
"Content-Type: application/json" http://gateway_ip/api/send_ussd
Response
{"request_id":1, "error_code":202, "result":[{"port":0,
"status":503},{"port":1, "status":503},{"port":2, "status":200}]}
Type
Description
Required Parameter
port
Array
Type
Description
error_code
Integer
Possible code,
200, Request has been processed.
400, Request format is not valid.
Array
8.4 Example
Request
http://gateway_ip/api/query_ussd_reply?port=1,2,3
Response
{"error_code":200, "reply":[{"port":1, "text":" "},{"port":2, "text":
"Test"},{"port":3, "text": ""}]}
Type
Description
Required Parameter
task_id
Integer
Type
Description
error_code
Integer
Possible code,
200, task has bee stop.
404, task not found
500, other error
9.4 Example
Request
http://gateway_ip/api/stop_sms?task_id=1
Response
{"error_code":200}
Type
Required Parameter
Description
info_type
Array
Optional Parameter
port
Array
Type
Description
error_code
Integer
Possible code,
200, Request has been processed.
400, Request format is not valid.
500, other error
info
Array
POWER_OFF
NO_SIM
PIN_REQUIRE
PUK_REQUIRE
UNREGISTER
SEARCHING_NETWORK
REGISTER_OK
UNKNOWN
10.4 Example
Request
http://gateway_ip/api/get_port_info?port=1,2,3&info_type=imei,ims
i,iccid,smsc,type,number,reg
Response
{"error_code":200, "info":[{"port":1,
"type":"WCDMA","imei":"863070017005173","imsi":"","iccid":"","sms
c":"","number":"","reg":"NO_SIM",},{"port":2,
"type":"GSM","imei":"358967042917201","imsi":"460016529802215","i
ccid":"89860114840400428150","smsc":"+8613010868500","number":"",
"reg":"REGISTER_OK",},{"port":3,
"type":"GSM","imei":"358967042917201","imsi":"","iccid":"","smsc"
:"","number":"","reg":"NO_SIM",}]}
port parameter is optional in sending SMS request. If you dont need to send
with request.
3.
If user_id is in the send SMS request, user_id will be included in the SMS result.
5.
to query delivery status after SENT_OK is returned. For a long SMS, for example,
with a number 123456, ref_id 0, totally sent by 3 parts, the ref_id of each part
will be 0, 1, 2. And at least 3 delivery status will be received, each with ref_id 0, 1 or
6.
information.