HTTPS API Command Format
The HTTPS API command parameters should be sent as HTTPS GET or HTTPS POST values. TextMagic recommends HTTPS POST, as the lengths of GET queries are limited.The text-message parameters should be encoded in the UTF-8 character set. All non-ASCII characters in command parameters should be encoded as described in RFC1738, “Uniform Resource Locators (URL)” https://www.ietf.org/rfc/rfc1738.txt, paragraph 2.2.
The URL encodings’ primary use is to encode URL strings into a form that can be passed via email or scripted-web links without altering the actual content in any way.
Example URL encoded strings
String | In URL encoded format |
---|---|
Свободная энциклопедия | %D0%A1%D0%B2%D0%BE%D0%B1%D0%BE%D0%B4%D0%BD%D0%B0%D1%8F+%D1%8D%D0%BD%D1%86%D0%B8%D0%BA%D0%BB%D0%BE%D0%BF%D0%B5%D0%B4%D0%B8%D1%8F |
フリー百科事典 | %E3%83%95%E3%83%AA%E3%83%BC%E7%99%BE%E7%A7%91%E4%BA%8B%E5%85%B8 |
The Free Encyclopedia | The+Free+Encyclopedia |
The basic command structure for all HTTP API commands is:
general URL + username=YourUserName + password=YourAPIPassword + cmd=CommandName + parameters
Mobile phone number format
All mobile phone numbers submitted via API should be in international format. Enter all numbers with country code, without leading zeroes and without spaces. For example:Country | Mobile phone number with country code |
---|---|
United Kingdom | 447772401111 |
Russia | 79057511111 |
Germany | 491722351111 |
Australia | 61421851111 |
South Africa | 27833911111 |
This API request will send SMS "Свободная энциклопедия" to two mobile phones.
Request
https://www.textmagic.com/app/api?username=xxxx&password=yyyy& cmd=send&text=%D0%A1%D0%B2%D0%BE%D0%B1%D0%BE%D0%B4%D0%BD%D0%B0%D1%8F+%D1%8D%D0%BD%D1%86%D0%B8%D0%BA%D0%BB%D0%BE%D0%BF%D0%B5%D0%B4%D0%B8%D1%8F&phone=44725334554%2C447123456789&unicode=1
Response
{
"message_id": {
"447253345545": "8294470",
"447123456789": "8294471"
},
"sent_text": "Свободная энциклопедия",
"parts_count": 1
}
"message_id": {
"447253345545": "8294470",
"447123456789": "8294471"
},
"sent_text": "Свободная энциклопедия",
"parts_count": 1
}
The general URL and username should be separated by a question mark (?) symbol. All other sections of the command must be separated by an ampersand (&) symbol. You can include up to 100 mobile phone numbers to a single send command, so if you need to send 2000 messages you need to complete 20 send commands.
Mandatory Parameters
The following three parameters are mandatory with all the commands:Variable | Value |
---|---|
username | The user name of your TextMagic account. |
password | Your TextMagic API password (get it here) |
cmd | The TextMagic command to be executed. |
The TextMagic API response returns in the Java Script Object Notation (JSON) array format. Even the error codes are returned in JSON encoded arrays. The encoding for response is UTF-8 and Content-Type: application/json.
Back to top