Partner sends HTTP request to the address
http://smscomm.vero.lt/partner/sms_packet.php.
Parameters must be URL-encoded and coded by UTF-8 format.
The data submitted via GET method:
Title |
Description |
Example |
username |
Username |
demo |
password |
Login password |
demo |
action |
Requested action, possible values: • validate_packet – bulk messages error check, sending will not be executed;
• send_packet – send bulk messages;
• get_packet – bulk messages sending and delivery statistics;
• validate_edit – unsent messages editing error check;
• edit – edit unsent messages;
• stop – stop sending messages;
• delete – delete unsent messages; |
send_packet |
HTTP POST |
Detailed action parameters, read more about their values by specified action description.
The parameters structure is encoded by JSON format and must be sent via HTTP POST method. |
array (
'ident' => 1323202186,
'sender' => 'VeroDemo',
'sms' => 'Demo SMS API message',
'messages' =>
array (
1 =>
array (
'phone' => '37065659515',
),
2 =>
array (
'phone' => '37060042751',
'sms' => 'Dear John. Demo SMS API message',
),
),
) |
After executing HTTP request, you will get JSON format response from MBS.
Response is formated by JSEND specifications (more on http://labs.omniti.com/labs/jsend/wiki).
It strictly defines 3 types of response:
* success;
* fail (eg. false data);
* error (exception, DB error, etc.);
HTTP request example:
http://smscomm.vero.lt/partner/sms_packet.php?username=demo&password=demo&action=send_packet
HTTP POST example:
{"ident":1323203033,"type":"SMS","sender":"VeroDemo","sms":"Demo SMS API message",
"messages":{"1":{"phone":"37065659515"},"2":{"phone":"37060042751",
"sms":"Dear John. Demo SMS API message"}}}
HTTP response example (success):
{"status":"success","data":{"sent":{"1":11021391,"2":11021392},"errors":[]}}
HTTP response example (fail):
{"status":"fail","data":{"sent":[],"errors":{"1":{"field":"phone",
"field_error":"Wrong MSISDN format"}}}}
validate_packet, send_packet
Action validate_packet is used to check bulk message text errors, sending will not be executed.
Action send_packet - to send bulk messages.
Request parameters:
Title |
Description |
Example |
messages |
Recipient's list - associative array containing key-value pairs:
• for value parameter „phone“ must be indicated - recipient's phone number (MSISDN), international format „370xxxyyyyy“;
• for key should be indicated recipient's unique identifier from the list. Later used to relate with sending errors;
• there is an option to add personalized data, same like with sending single message. Eg., if the „sms“ parameter is specified, it can be other message text formed for specific recipient; |
array(
'1' => array(
'phone' => '37065659515',
),
'2' => array(
'phone' => ' 37060042751',
'sms' => ' Dear John. Demo SMS API message
)); |
skip_errors |
(not necessary) How to treat error messages (possible just for send_packet action):
0 – if there were some errors, sending is not executed (default);
1 - send messages no matter what, just skip those with errors; |
0 |
sender |
(not necessary) Sender's phone number. Option can be activated by a separate agreement, in advance specifying what values will be used |
VeroDemo |
sms |
(not necessary) Message text (if WapPush, link title - tekstas) |
Demo SMS API message |
ident |
(not necessary) External system identifier, eg. sending id |
news-reminder-12345 |
... |
(not necessary) All other parameters used for sending single message are also available for sending bulk. |
|
Response parameters:
Status |
Description |
Example |
success |
All messages or part of them sent successfuly. Returns:
• sent – MBS accepted messages and gave them unique identifiers - SMS_ID;
• errors – MBS did not accept messages (if parameter skip_errors=1 is used); |
array(
'status' => 'success',
'data' => array(
'sent' => array(
'1' => 12345,
'2' => 12346,
),
'errors' => array()
)) |
fail |
Messages were not sent because of wrong data. Returns:
• errors – MBS did not accept messages and errors;
• field – which field caused error;
• field_error – error description; |
array(
'status' => 'success',
'data' => array(
'sent' => array(),
'errors' => array(
'3' => array(
'field' => 'phone',
'field_error' => 'Wrong msisdn format')
)
)) |
error |
Critical or unknown connection error |
array(
'status' => 'error',
'message' => 'Fatal DB error',
) |
get_packet
Action get_packet is used to check mass message sending and delivery statistics.
Request parameters:
Title |
Description |
Example |
ident |
Specify by external system identifier which messages should be checked |
news-reminder-12345 |
Response parameters:
Status |
Description |
Example |
success |
Returns mass message info:
• ident – external system identifier;
• stats_overal – total number of messages;
• stats_sent – how many messages sent already;
• stats_delivered – how many messages delivered;
• stats_length – how many packages you will have to pay (one package consists of 160 characters); |
array(
'status' => 'success',
'data' => array(
'ident' => 'news-reminder-12345',
'stats_overal' => '100',
'stats_sent' => '100',
'stats_delivered' => '87',
'stats_length' => '87',
)) |
error |
Critical or unknown connection error |
array(
'status' => 'error',
'message' => 'Fatal DB error',
) |
validate_edit, edit
Action validate_edit is used to check edited messages errors, real editing will not be executed. Action edit is used to edit unsent messages (single message or all package).
Remember, editing actions (edit, stop, delete) can be applied for messages that are not sent yet. Send messages will not be changed.
Request parameters:
Title |
Description |
Example |
ident |
Specify by external system identifier which messages should be checked |
news-reminder-12345 |
message_id |
(not necessary) Specify which messages should be edited, by unique MBS identifier or array of identifiers |
array(12345, 12346, 12347) |
sender |
(not necessary) If you want to edit sender's phone number |
VeroDemo |
sms |
(not necessary) If you want to edit message text (if WapPush - link title) |
Demo SMS API message |
new_ident |
(not necessary) If you want to edit external system identifier, eg., option to form new package of edited messages |
news-reminder-12346 |
... |
(not necessary) All other parameters used for sending single message are available for editing. |
|
Response parameters:
Status |
Description |
Example |
success |
All messages were edited successfuly. Returns:
• edited – amount of edited messages; |
array(
'status' => 'success',
'data' => array(
'edited' => 125,
)) |
fail |
Messages were not edites because of wrong data. Returns:
• field – which field caused error;
• field_error – error description; |
array(
'status' => 'fail',
'data' => array(
'field' => 'message',
'field_error' => 'Empty sending text',
)) |
error |
Critical or unknown connection error |
array(
'status' => 'error',
'message' => 'Fatal DB error',
) |
stop
Action stop is used to stop sending messages for an indefinite period (single message or all package).
Remember, editing actions (edit, stop, delete) can be applied for messages that are not sent yet. Sent messages will not be influenced.
Request parameters:
Title |
Description |
Example |
ident |
Specify by external system identifier which messages should be stopped |
news-reminder-12345 |
message_id |
(not necessary) Specify which messages should be stopped, by unique MBS identifier or array of identifiers |
array(12345, 12346, 12347) |
new_ident |
(not necessary) If you want to edit external system identifier, eg., option to form new package of stopped messages |
news-reminder-12346 |
Response parameters:
Status |
Description |
Example |
succes |
All messages were stopped successfuly. Returns:
• edited – amount of stopped messages; |
array(
'status' => 'success',
'data' => array(
'edited' => 125,
)) |
error |
Critical or unknown connection error |
array(
'status' => 'error',
'message' => 'Fatal DB error',
) |
delete
Action delete is used to permanently remove unsent messages (single message or all package).
Remember, editing actions (edit, stop, delete) can be applied for messages that are not sent yet. Sent messages will not be influenced.
Request parameters:
Title |
Description |
Example |
ident |
Specify by external system identifier which messages should be deleted |
news-reminder-12345 |
message_id |
(not necessary) Specify which messages should be edited, by unique MBS identifier or array of identifiers |
array(12345, 12346, 12347) |
Response parameters:
Status |
Description |
Example |
success |
Messages were deleted successfuly. Returns:
• deleted – amount of edited messages; |
array(
'status' => 'success',
'data' => array(
'deleted' => 125,
)) |
error |
Critical or unknown connection error |
array(
'status' => 'error',
'message' => 'Fatal DB error',
) |
EXAMPLE
The bulk message is sent to some users and the result is printed to the screen.
If you work with PHP language you can use MBS PHP library class SMSComm.
If you don't want to use MBS PHP library, you should rewrite some functions, eg., sendPacket(), _callPacketAction(), _sendRequest()
< !--?php
/**
* Raw mass SMS sending example
*
* @see MBSLib/examples/simple/send_sms_packet.php
*
* @package RawExamples
* @author Valdas Petrulis
*/
include_once(dirname(__FILE__).'/../../lib/SMSComm.class.php');
try {
// Init SMS API client with wanted configuration
define('SMSCOMM_USERNAME', 'demo');
define('SMSCOMM_PASSWORD', 'demo');
$client = new SMSComm(SMSCOMM_USERNAME, SMSCOMM_PASSWORD);
$client->setDebug(true);
// Send mass SMS
$ident = time();
$messages = array(
1 => array('phone' => '37065659515'),
2 => array('phone' => '37060042751', 'sms' => 'Dear John. Demo SMS API message'),
);
$result = $client->sendPacket
($messages, false, 'VeroDemo', 'Demo SMS API message', null, $ident);
if ($result['status']=='success') {
echo 'Sent '. count
($result['data']['sent']) .' SMS messages, '. count($result['data']['errors']) .' errors';
} else {
echo 'Errors in SMS messages: '.var_export($result['data']['errors'], true);
}
// Watch sending/delivery statistics
$stats = $client->getPacket($ident);
echo 'Packet information: '. var_export($stats, true);
} catch(Exception $e) {
echo "Error in SMS API: " . $e;
}
?>
EXAMPLE (REFERENCE LIBRARY)
PHP library used to connect to the Vero system, you can download here: MBS library