HTTP API - Receive SMS
GET https://gateway_ip/api/query_incoming_sms
Request Parameters:
Parameter | Type | Description |
Optional Parameter | ||
incoming_sms_id | Integer | It is an integer greater than 0
When a SMS server/client request for SMS messages, the gateway will return the messages whose ID are greater than this value to SMS server/client Default value is 0 |
flag | String | Optional values of this parameter include:
"unread": unread SMS messages (whose status will change to ‘read’ after they are read by this API) "read": SMS messages that have been read "all": SMS messages that are unread and read Default value is "unread" |
port | Array of Integers | Port(s) for receiving SMS messages
Each port should be an integer ranging from 0 to 31 |
Response Parameters:
Parameter | Type | Description |
error_code | Integer | Codes that may be returned:
200:it is legal request and gateway will return SMS messages according to the request. 500: Other errors |
sn | String | SN of the gateway |
sms | Array of Object | SMS messages; each message include the following information:
incoming_sms_id: message ID in gateway’s database port: port of receiving SMS message number: telephone number of SMS sender smsc: telephone number of SMS center timestamp: time of receiving SMS message text: content of a SMS message |
read | Integer | count of SMS messages that have been read. |
unread | Integer | count of SMS messages that are unread. |
Example of Receiving SMS:
Request:
https://gateway_ip/api/query_incoming_sms?flag=all
Response:
{"error_code":200,"sn":"xxxx-xxxx-xxxx-xxxx","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}
Incoming sms can also be pushed to your application:
{"sn":"da00-0030-1901-2817","sms":[{"incoming_sms_id":1,"port": 1,"number":"6717","smsc":"+8613800757511","timestamp":"2016-07
-12 15:46:18","text":"test"}]}
Suggestion:
- Push Service for getting SMS.
- Incoming sms id should be increased every time. For example, First request, without incoming_sms_id is OK. But Seconde request, the incoming_sms_id should be the max id in the first response.