To send text messages via NGW, a simple HTTP interface is implemented.
To send a command, curl utility is used.
To send SMS, the command should have the following format:
$ curl -Xpost localhost:8040/api/sms --data '{ "phone": "79831300000", "message": "http hello"}' -H 'Content-Type: application/json' -i
If command processing and message sending are successful, the response will be:
HTTP/1.1 200 OK Date: Wed, 13 Dec 2017 12:05:52 GMT Content-Type: application/json;charset=utf-8 Transfer-Encoding: chunked Server: Jetty(9.4.3.v20170317) { "code": 0, "detail": "Sms is sent successfully on Smsc. ID: adc2f952-3a24-4148-910f-d5a9b77c85c5, parts in SMS: 1, cost: 0, balance: 51.144" }
If a failure occurs during command processing, for example, when the number is incorrect:
$ curl -Xpost localhost:8040/api/sms --data '{ "phone": "79831300000asdf", "message": "http hello"}' -H 'Content-Type: application/json' -i
The server will return the following error:
HTTP/1.1 500 Server Error Date: Wed, 13 Dec 2017 12:07:15 GMT Content-Type: application/json;charset=utf-8 Transfer-Encoding: chunked Server: Jetty(9.4.3.v20170317) {"message": "Received error code = 7. Incorrect format of phone number"}
Command format for e-mail sending:
curl -Xpost localhost:8040/api/email --data '{"subject": "http email", "to": "example@example.loc", "message": "http hello"}' -H 'Content-Type: application/json' -i
The server response on a successful sending:
HTTP/1.1 200 OK Date: Wed, 13 Dec 2017 12:05:27 GMT Content-Length: 0 Server: Jetty(9.4.3.v20170317)