Page 1 of 1

Usage of SMS API

PostPosted: 18/02/2015, 12:07
by matteo.erba
SMS API allows any external software to use the Wildix PBX as an SMS Server with the possibility of bulk (mass) SMS sending.

To send an SMS:
Make an HTTP POST/GET request with basic authorization (username/password of the user who is the SMS sender) to http(s)://<PBX_IP_Address>/api/v1/orginate/sms

In case the GSM gateway to be used for SMS sending is not specified in the command, the message is sent to a randomly chosen GSM gateway configured in the system.

The timeout for mass sending is 5 sec for each SMS / gateway.

The POST/GET required parameters are
    message: the body SMS messages, length of no more than 300 characters
    number: the phone number or several numbers separated by a comma. Example: +391234567890 or +391234567890,+391234567891,+391234567892,...


The POST/GET optional parameters are
    postpone: date of postponed message delivery. Example: 14/07/2014 15:35
    gsm: GSM gateway MAC address. Example: 9c7514330001

The response of the serivce is
    Success: {"type":"result","result":"Success"}
    Warning: {"type":"warning","reason":"Unable to add a SMS to the queue","result":["111"]}
    Error: {"type":"error","reason":"Number should not be empty","result":null}
The "reason" part is the description of the warning/error

To try the service you can use the curl software and run it from the command line.
Here is a working example on a test system:
Code: Select allcurl -k -X POST -u 101:sms101api --url "https://192.168.1.254/api/v1/originate/sms"  --data-urlencode "number=+39123456789" --data-urlencode "message=This API is awesome, now I can add the sms support to my software" --data-urlencode "gsm=9c7514330001"



And here an example on the dialplan

Code: Select allSet->CURLOPT(userpwd) - 101:sms101api
Custom application-> Set(message=${CURL(http://127.0.0.1/api/v1/originate/sms, message=This API is awesome, now I can add the sms support to my software&number=%2B39333123456)});

sms_api_dialplan.png
sms_api_dialplan.png (31.69 KiB) Viewed 9847 times


Note: the %2B added to the mobile number is the + character with URL encoding transformation. The full reference is available on the w3school web site.

Re: Usage of SMS API

PostPosted: 08/05/2015, 10:15
by marco.randon@newcomm.it
Good morning,
on the response doc add:
{"type":"error","reason":"Unauthorized","result":null}

Marco - NEW snc

Re: Usage of SMS API

PostPosted: 08/05/2015, 10:18
by marco.randon@newcomm.it
It would not be better to return an error code also?

Thank you,
Marco - NEW snc

Re: Usage of SMS API

PostPosted: 08/05/2015, 13:30
by matteo.erba
Hello Marco,
this is a good suggestion, I will forward it to the developing team.

Thank you

Re: Usage of SMS API

PostPosted: 11/05/2015, 10:19
by marco.randon@newcomm.it
Good morning,
on the response doc add:
{"type":"error","reason":"GSM gateway not found","result":null}

Marco - NEW snc

Re: Usage of SMS API

PostPosted: 11/05/2015, 10:36
by marco.randon@newcomm.it
Hello,
I think MAC address standards say that letters goes uppercase.
It's weird to note that this API do not accept MAC address with uppercase letters.

Good bye,
Marco - NEW snc

Re: Usage of SMS API

PostPosted: 11/05/2015, 10:53
by marco.randon@newcomm.it
Good morning,
on the response doc add:
{"type":"error","reason":"Message longer than 300 characters","result":null}

Marco - NEW snc