PHP code example of developingw / turbosmsua

1. Go to this page and download the library: Download developingw/turbosmsua library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

developingw / turbosmsua example snippets




use DevelopingW\TurboSMSua\API;

$smsApi = new API($_ENV['TURBOSMS_KEY']);

$balance = $smsApi->getUserBalance();

print_r($balance);

Array (
    [balance] => 2106.42
)



use DevelopingW\TurboSMSua\API;

$smsApi = new API($_ENV['TURBOSMS_KEY']);

$senderList = $smsApi->getSMSDefaultSenders();

print_r($senderList);

Array (
    [
        'TAXI',
        'SERVIS TAXI',
        'Dostavka24',
        'MAGAZIN',
        'IT Alarm',
        'AKCIYA',
        'BEAUTY',
        'Best-Shop',
        'BonusShop',
    ]
)



use DevelopingW\TurboSMSua\API;

$smsApi = new API($_ENV['TURBOSMS_KEY']);

$senderList = $smsApi->getViberDefaultSenders();

print_r($senderList);

Array (
    [
        
    ]
)



use DevelopingW\TurboSMSua\API;
use DevelopingW\TurboSMSua\REQUEST_CODE;

$smsApi = new API($_ENV['TURBOSMS_KEY']);

$message1 = $smsApi->messageSend('380001111111', 'TEXT Message');
$message2 = $smsApi->messageSend('380001111111', 'TEXT Message', 'MAGAZIN');

print_r($message1);
print_r($message2);

$messageList = array_merge($message1, $message2);
foreach ($messageList as $m) {
    print_r(REQUEST_CODE::getEN($m['response_code']));
    print_r(REQUEST_CODE::getRU($m['response_code']));
    print_r(REQUEST_CODE::getUA($m['response_code']));
}

Array (
    [0] => stdClass Object (
		[phone] => 380001111111
		[message_id] => f3ab7c22-9481-8d1d-4fa6-00a9e0e6cf67
		[response_code] => 0
		[response_status] => OK
	)
)
Array (
    [0] => stdClass Object (
		[phone] => 380001111111
		[message_id] => f4ab7c22-2371-7d2d-4fa6-00a9e0e4cf68
		[response_code] => 0
		[response_status] => OK
	)
)

"Request processed successfully."
"Запрос обработан успешно."
"Запит оброблено успішно."



use DevelopingW\TurboSMSua\API;

$smsApi = new API($_ENV['TURBOSMS_KEY']);

// This message will be sent at the specified time.
$message1 = $smsApi
                ->setStartTime(\DateTime::createFromFormat('d.m.Y H:i', '10.12.2023 9:00'));
                ->messageSend('380001111111', 'TEXT Message');
                
// This message will be sent via Viber.
$message2 = $smsApi
                ->setMode('viber')
                ->messageSend('380001111111', 'TEXT Message', 'MAGAZIN');
                
// This message will be sent via Viber and SMS.
// With an additional condition, the maximum lifespan of the Viber message is 60 seconds.
$message3 = $smsApi
                ->setMode('hybrid')
                ->setTTL(60)
                ->messageSend('380001111111', 'TEXT Message', 'YOUR SENDER');

print_r($message1);
print_r($message2);
print_r($message3);

Array (
    [0] => stdClass Object (
		[phone] => 380001111111
		[message_id] => f3ab7c22-9481-8d1d-4fa6-00a9e0e6cf67
		[response_code] => 0
		[response_status] => OK
	)
)
Array (
    [0] => stdClass Object (
		[phone] => 380001111111
		[message_id] => f4ab7c22-2371-7d2d-4fa6-00a9e0e4cf68
		[response_code] => 0
		[response_status] => OK
	)
)
Array (
    [0] => stdClass Object (
		[phone] => 380001111111
		[message_id] => f9ag2d21-3381-8d3d-2fa8-01b9e0e4cf69
		[response_code] => 0
		[response_status] => OK
	)
)



use DevelopingW\TurboSMSua\API;

$smsApi = new API($_ENV['TURBOSMS_KEY']);

$status = $smsApi->messageStatus('f3ab7c22-9481-8d1d-4fa6-00a9e0e6cf67'); 
$statusList = $smsApi->messageStatus(['f4ab7c22-2371-7d2d-4fa6-00a9e0e4cf68']);

print_r($status);
print_r($statusList);

Array (
    Array (
        [0] => stdClass Object (
            [message_id] => f3ab7c22-9481-8d1d-4fa6-00a9e0e6cf67
            [response_code] => 0
            [recipient] => 380001111111
            [sent] => 2023-12-12 16:00:52
            [updated] => 2023-12-12 16:01:00
            [status] => Delivered
            [type] => sms
            [response_status] => OK
        )
    )
)
Array (
    Array (
        [0] => stdClass Object (
            [message_id] => f4ab7c22-2371-7d2d-4fa6-00a9e0e4cf68
            [response_code] => 0
            [recipient] => 380001111111
            [sent] => 
            [updated] => 2023-12-11 15:02:00
            [status] => Queued
            [type] => sms
            [response_status] => OK
        )
    )
)