XML Send SMS
Why XML API
- It is not possible for a URL to take too much data in GET method and have to use POST method
- It enables few extra features like sending custom SMS
- Sending 500 SMS will take 5 loop in HTTP API but none in XML, thus saving your resources and ours too
- If you face any issue, take help of our engineers
Sample XML format:
<MESSAGE>
<AUTHKEY>Authentication Key </AUTHKEY>
<SENDER>SenderID</SENDER>
<ROUTE>Template</ROUTE>
<CAMPAIGN>XML API</CAMPAIGN>
<COUNTRY>country code</COUNTRY>
<SMS TEXT="message1" >
<ADDRESS TO="number1"></ADDRESS>
<ADDRESS TO="number2"></ADDRESS>
</SMS>
<SMS TEXT="hi test message" >
<ADDRESS TO="number3"></ADDRESS>
</SMS>
</MESSAGE>
Post your request with above format in data variable.
http://api.msg91.com/api/postsms.php
XML node name | Description |
---|---|
AUTHKEY * | User authentication key |
TEXT * | It contains the URL encoded message content to send |
SENDER * | It contains sender ID |
TO * | It contain mobile numbers |
SCHEDULE DATE TIME | It contains scheduled date and time |
FLASH | 1 |
UNICODE | 1 |
ROUTE | Route name if you have more than one route available in your account |
CAMPAIGN | It contains campaign name |
COUNTRY | 0 for international, 91 for India, 1 for USA |
Call API
To generate API or to test your XML code, please set the parameters in the text area below
data : |
Output:
Optional: none
http://api.msg91.com/api/ValidateXml.php
<MESSAGE>
<AUTHKEY>Authentication key</AUTHKEY>
<ROUTE>default</ROUTE >
<CAMPAIGN>BULKSMS</CAMPAIGN >
<COUNTRY>country code</COUNTRY>
<SENDER>SenderID</SENDER>
<SCHEDULEDATETIME>2016-03-31 11:17:39 </SCHEDULEDATETIME>
<SMS TEXT="hii this is test message">
<ADDRESS TO="number1"></ADDRESS>
<ADDRESS TO="number2"></ADDRESS>
</SMS>
</MESSAGE>
returns json response with success if all parameters are correct or error with appropriate error message.
Response Type | Response Message | Description |
---|---|---|
success | XML code is correct. | Returns success for validate XML API call. |
error | XML code should not be blank. | Returns error in case of 'testingsXml' parameter is missing or empty. |
error | Specific error message. | Returns error in case of ill constructed XML API and displays appropriate error message. |
Send message on single number
<MESSAGE>
<AUTHKEY>Authentication Key</AUTHKEY>
<ROUTE>Template</ROUTE>
<CAMPAIGN>TRIAL</CAMPAIGN>
<COUNTRY>country code</COUNTRY>
<SENDER>SenderID</SENDER>
<SMS TEXT="Hi this is a test message">
<ADDRESS TO="9999999990"></ADDRESS>
</SMS>
</MESSAGE>
To send message on multiple numbers, use <ADDRESS> tag multiple times with different mobile numbers. Above API example can be modified to send single message on two mobile numbers
Schedule Message
<MESSAGE>
<AUTHKEY>Authentication Key</AUTHKEY>
<ROUTE>default</ROUTE>
<CAMPAIGN>BULKSMS</CAMPAIGN>
<COUNTRY>country code</COUNTRY>
<SENDER>SenderID</SENDER>
<SCHEDULEDATETIME>2024-04-27 01:17:42</SCHEDULEDATETIME>
<SMS TEXT="hii this is test message">
<ADDRESS TO="9999999990"></ADDRESS>
</SMS>
</MESSAGE>
To send schedule message one more tag <SCHEDULEDATETIME> will be added and it will contain scheduled date and time
Sending customize message
<MESSAGE>
<AUTHKEY>Authentication Key</AUTHKEY>
<SENDER>SenderID</SENDER>
<SMS TEXT="hii this is test message">
<ADDRESS TO="9999999990"></ADDRESS>
</SMS>
<SMS TEXT="hii this is second test message">
<ADDRESS TO="9999999991"></ADDRESS>
</SMS>
</MESSAGE>
This API can be used to send different messages on different numbers, simply by adding another <SMS> tag with different message content in TEXT
Sending message using route
<MESSAGE>
<AUTHKEY>Authentication Key</AUTHKEY>
<ROUTE>default</ROUTE>
<CAMPAIGN>CUSTOM SMS</CAMPAIGN>
<SENDER>SenderID</SENDER>
<SMS TEXT="hii this is test message">
<ADDRESS TO="9999999990"></ADDRESS>
</SMS>
</MESSAGE>
Above API can be used to send SMS using route and it can be done easily by adding one more tag i.e. <ROUTE> tag and it's value should be either default or template other wise message will be processed from default route
Flash message
<MESSAGE>
<AUTHKEY>Authentication Key</AUTHKEY>
<ROUTE>default</ROUTE>
<CAMPAIGN>FLASH SMS</CAMPAIGN>
<SENDER>SenderID</SENDER>
<FLASH>1</FLASH>
<SMS TEXT="hii this is test message">
<ADDRESS TO="9999999990"></ADDRESS>
</SMS>
</MESSAGE>
To send flash message one more tag <FLASH> will be added and it will contain 1
Unicode message
<MESSAGE>
<AUTHKEY>Authentication Key</AUTHKEY>
<ROUTE>default</ROUTE>
<CAMPAIGN>UNICODE SMS</CAMPAIGN>
<SENDER>SenderID</SENDER>
<UNICODE>1</UNICODE>
<SMS TEXT="hii this is test message">
<ADDRESS TO="9999999990"></ADDRESS>
</SMS>
</MESSAGE>
To send unicode message one more tag <UNICODE> will be added and it will contain 1
WHAT IS XML
XML (Extensible Markup Language) is a flexible way to create common information formats and share both the format and the data on Internet. As in HTML,it has it's own predefined tags while what makes XML flexible is that custom tags can be defined and the tags are invented by the author of the XML document.
Encode your message
What is HTML encoding?
The HTML character encoder converts all applicable characters to their corresponding HTML entities. Certain characters have special significance in HTML and should be converted to their correct HTML entities to preserve their meanings. For example, it is not possible to use the < character as it is used in the HTML syntax to create and close tags. It must be converted to its corresponding < HTML entity to be displayed in the content of an HTML page. HTML entity names are case sensitive.
Example:
<MESSAGE>
<AUTHKEY>Authentication Key</AUTHKEY>
<ROUTE>default</ROUTE>
<SENDER>SenderID</SENDER>
<SMS TEXT="your password is: "0989898" ">
<ADDRESS TO="9999999990"></ADDRESS>
</SMS>
</MESSAGE>
In this API the message content "your password is: "0989898" " includes " (double quotes) operator, due to which HTML encoding is necessary, otherwise it will break your XML and an error will be occur
Encoded API
<MESSAGE>
<AUTHKEY>Authentication Key</AUTHKEY>
<ROUTE>default</ROUTE>
<SENDER>SenderID</SENDER>
<SMS TEXT="your password is: "0989898" ">
<ADDRESS TO="9999999990"></ADDRESS>
</SMS>
</MESSAGE>
By encoding HTML special characters in API, will not break your XML