Send an SMS using XML API
To send an SMS using XML API, the following format is used:
'curl -X POST \
'<BASE_URL>&method=sms.xml&xml=%3C%3Fxml%20version%3D%221.0%22%20encoding.....'
Below is the sample xml data before url encoding. You have to send below xml in post method.
Sample XML Data
<?xml version="1.0" encoding="UTF-8"?>
<xmlapi>
<sender>AAAAAA</sender>
<message>xml test</message>
<unicode>1</unicode>
<flash>1</flash>
<campaign>xml test</campaign>
<dlrurl>
<![CDATA[http://domain.com/receive?sent={sent}&delivered={delivered}&msgid={msgid}&sid={sid}&status={status}&reference={reference}
&custom1={custom1}&custom2={custom2}&credits={credits}]]>
</dlrurl>
<sms>
<to>95xxxxxxxx</to>
<custom>22</custom>
<custom1>99</custom1>
</sms>
<sms>
<to>99xxxxxxxx</to>
<custom>229</custom>
<custom1>995</custom1>
</sms>
</xmlapi>'
SMS can be sent using the XML API by posting values to the preceding URL by the POST method or the GET method.
API Parameter Specifications
The API parameter specifications are described in the following sections.
Mandatory Parameters
The mandatory parameters in the HTTP API are tabulated below:
Parameter | Description | Expected Values |
---|---|---|
BASE_URL | BASE URL of your SMS Service | URL |
method | Predefined method | sms.xml |
xml | You can provide either URL encoded XML data directly or URL of the XML file | Valid XML document or link of XML document |
Optional Parameter
The Optional parameters in the HTTP API are tabulated below:
Parameter | Description | Expected Values |
---|---|---|
format | Output format should be as specified by this variable | XML/JSON/JSONP. Default JSON |
callback | Callback function for JSONP response format | Javascript function name standards |
XML Tag Parameters
NOTE: If message,sender and dlrurl is specified within both SMS tag and XML tag, the former overrides the later.
Parameter | Description | Expected Values | Type |
---|---|---|---|
xml version="1.0 "encoding="UTF-8" | XML Header | Version and Encoding | Mandatory |
api | Document Root | Document Root | Mandatory |
flash | Global node for flash | 1/0 | Optional |
campaign | Global campaign name tag | campaign name | Optional |
sms | SMS Node(can repeat) | SMS Node | Mandatory |
to | Mobile number in sms node | Comma separated 10 digit mobile numbers | Required |
custom | Message ID for sms | comma separated message ID's | Optional |
custom1 | Custom reference 1 (comma separate) | comma separated custom 1 references | Optional |
custom2 | Custom reference 2 (comma separate) | comma separated custom 2 references | Optional |
sender | Sender ID assigned to your account | Sender ID | Mandatory |
message | Message to be sent. In case of any special characters in your message, enclose it within CDATA a s in the example | Message text | Mandatory |
dlrurl | The URL to receive delivery reports. Spiffing reference id is mandatory | EX:http://www.example.com/dlr.php |
Optional |
unicode | To specify that the message to be sent is in unicode format.Also can be used for automatic detection of unicode SMS | 1/0/auto | Optional |
time | Global schedule time | EX Format: YYYY-MM-DD HH:MM:SS OR YYYY-MM-DD HH:MM AM/PM | Optional |
- Sample Data: In case of special characters in the content within any of the XML tags, enclose it within CDATA as in following examples.
a. Sending to multiple numbers with same message
<?xml version="1.0" encoding="UTF-8"?>
<api>
<campaign>campaign</campaign>
<dlrurl>
<![CDATA[http://domain.com/receive?msgid={msgid}&sid={sid}&status={status}&custom1={custom1}]]>
</dlrurl>
<time>2014-12-26 04:00pm</time>
<unicode>0</unicode>
<flash>0</flash>
<sender>senderid</sender>
<message><![CDATA[smstext]]></message>
<sms>
<to>9190********</to>
</sms>
<sms>
<to>9191********</to>
</sms>
</api>
b. Sending to multiple numbers with different message
<api>
<campaign>campaign</campaign>
<time>2014-12-26 04:00pm</time>
<unicode>0</unicode>
<flash>0</flash>
<sms>
<to>9190********</to>
<sender>senderid</sender>
<message>smstext</message>
<custom>2</custom>
<dlrurl>
<![CDATA[http://domain.com/receive?msgid={msgid}&sid={sid}&status={status}&custom1={custom1}]]>
</dlrurl>
</sms>
<sms>
<to>9191********</to>
<sender>senderid</sender>
<message><![CDATA[smstext]]></message>
<custom>2</custom>
<dlrurl>
<![CDATA[http://domain.com/receive?msgid={msgid}&sid={sid}&status={status}&custom1={custom1}]]>
</dlrurl>
</sms>
</api>
Example Responses
JSON
{
"status": "OK",
"data": [
{
"id": "811436f5-0053-4ea6-8cac-b035880b8473:1",
"customid": "1",
"customid1": "11",
"customid2": "22",
"mobile": "95XXXXXXXXX",
"status": "AWAITED-DLR"
},
{
"id": "811436f5-0053-4ea6-8cac-b035880b8473:2",
"customid": "2",
"customid1": "1",
"customid2": "2",
"mobile": "97XXXXXXXX",
"status": "AWAITED-DLR"
}
],
"message": "Campaign of 2 numbers Submitted successfully."
}