SMS API
We offer additional capabilities for you by means of connection to our SMS API service. Now you have an opportunity to become integrated with our platform and entirely automate SMS distribution process.
To activate API on your account you need to send request in your profile for enabling Sms API.
Message sending
Example of a request for message delivery to 4 respondents:If message is queued successfully, this answer will send with the messages id:
<?xml version="1.0" encoding="UTF-8"?> <request> <auth> <login>380501234567</login> <password>p1a2s3s4</password> </auth> <message> <from>Sender</from> <text>Test message.</text> <recipient>380501234567</recipient> <recipient>380501234568</recipient> <recipient>380677654323</recipient> <recipient>380677654324</recipient> </message> </request>
If errors was happen:
<?xml version="1.0" encoding="UTF-8"?> <response> <name>Complete</name> <description>4 messages put into queue</description> <sms_id>633217</sms_id> <sms_id>633218</sms_id> <sms_id>633219</sms_id> <sms_id>633220</sms_id> </response>
Error codes:
<?xml version="1.0" encoding="UTF-8"?> <response> <name>Error</name> <description>Error code</description> </response>
- NO_DATA (data error : XML wasn’t transmitted)
- WRONG_DATA_FORMAT (transmitted XML format error)
- REQUEST_FORMAT (wrong request type)
- AUTH_DATA (authorization error: non-existent user, the user name or password is incorrect)
- API_DISABLED (work with API is disabled for user account)
- USER_NOT_MODERATED (sending Messages without user account verification is forbidden)
- INCORRECT_FROM (nvalid sender (addresser) name)
- INVALID_FROM (invalid sender name for this account)
- MESSAGE_TOO_LONG (Maximum length of the message is exceeded : 402 signs for Cyrillic characters, 459 signs for the Roman characters)
- NO_MESSAGE (empty message for sending)
- MAX_MESSAGES_COUNT (maximum number of respondents is exceeded for one request: 50)
- NOT_ENOUGH_MONEY (Not enough credit for sending a message to respondents in the request)
- UNKNOWN_ERROR (unknown error)
- INCORRECT_RECIPIENT_ (will indicate the first incorrect number from the list to be excluded and resend the request; will not send sms to everyone from the list)
Message status receiving
Example of a request for receiving a status of an id message:If the message is found, an answer specifying its status will be given.
<?xml version="1.0" encoding="UTF-8"?> <request> <auth> <login>380671234567</login> <password>p1a2s3s4</password> </auth> <sms_id>632647</sms_id> </request>
Possible status:
<?xml version="1.0" encoding="UTF-8"?> <response> <name> Status</name> <description>Message status</description> </response>
- MESSAGE_IS_DELIVERED (message was delivered to a respondent)
- MESSAGE_IS_SENT (message is sent)
- MESSAGE_NOT_DELIVERED (message wasn’t delivered)
- MESSAGE_IN_QUEUE (message is waiting to be sent)
Errors codes:
<?xml version="1.0" encoding="UTF-8"?> <response> <name>Error</name> <description>Error code</description> </response>
- NO_DATA (data error: XML wasn’t transmitted)
- WRONG_DATA_FORMAT (transmitted XML format error)
- REQUEST_FORMAT (incorrect request format)
- AUTH_DATA (authorization error: non-existent user, user name or password is incorrect)
- API_DISABLED (work with API is disabled for user account)
- MESSAGE_NOT_EXIST (message with id given is invalid)
- UNKNOWN_ERROR (unknown error)
Receiving user’s balance
Example of a request for user’s balance receiving:Answer:
<?xml version="1.0" encoding="UTF-8"?> <request> <auth> <login>380671234567</login> <password>p1a2s3s4</password> </auth> <balance /> </request>
If error is occured:
<?xml version="1.0" encoding="UTF-8"?> <response> <name>Balance</name> <description>amount of funds deposited in user account</description> <currency>user account currency</currency> </response>
Error codes:
<?xml version="1.0" encoding="UTF-8"?> <response> <name>Error</name> <description>error code</description> </response>
- NO_DATA (data error : XML wasn’t transmitted)
- WRONG_DATA_FORMAT (transmitted XML format error)
- REQUEST_FORMAT (wrong request type)
- AUTH_DATA (authorization error: non-existent user, the user name or password is incorrect)
- API_DISABLED (work with API is disabled for user account)
- UNKNOWN_ERROR (unknown error)
Code example for sending a request and receiving a reply in XML format in PHP language
<?php
$sUrl = 'https://api.letsads.com';
$sXML = '<?xml version="1.0" encoding="UTF-8"?>
<request>
<auth>
<login>380501234567</login>
<password>p1a2s3s4</password>
</auth>
<balance />
</request>';
$rCurl = curl_init($sUrl);
curl_setopt($rCurl, CURLOPT_HEADER, 0);
curl_setopt($rCurl, CURLOPT_POSTFIELDS, $sXML);
curl_setopt($rCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($rCurl, CURLOPT_POST, 1);
$sAnswer = curl_exec($rCurl);
curl_close($rCurl);
Your message sent successfully.
Send one more message.