PHP code example of spiti / smsclient

1. Go to this page and download the library: Download spiti/smsclient 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/ */

    

spiti / smsclient example snippets


php composer.phar install

php composer.phar 



ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);

use SmsClient\DevinoSMS\Api;

$devinoSMS = new Api('login', 'password');
// пример установки таймаута в секундах, по дефолту используется 1 секунда
$devinoSMS->getClinet()->setTimeout(2);

try {
    $sessionID = $devinoSMS->getSessionID();
    echo "<h2>SessionID: {$sessionID}</h2><hr />";
    echo "<h2>Balance: {$devinoSMS->getBalance()} руб</h2>";

    $list = $devinoSMS->send('test', '7905000000', 'Тестовое сообщение!');
    $id = reset($list);
    echo "<h2>Send SMS: {$id}</h2>";

    $list = $devinoSMS->sendByTimeZone('test', '7905000000', 'Тестовое сообщение с учетом часового пояса!', '2015-07-09T11:55:00');
    $id = reset($list);
    echo "<h2>Send SMS By Time Zone: {$id}</h2>";

    $list = $devinoSMS->send('test', array('7905000000', '7905000001'), 'Массовое тестовое сообщение!');
    $mes = print_r($list, true);
    echo "<h2>Send SMS Bulk: {$mes}</h2>";

    $result = $devinoSMS->getSMSStatus($id);
    $mes = print_r($result, true);
    echo "<h2>SMS Status: {$mes}</h2>";
    
    $result = $devinoSMS->getStatistics('2015-07-09T09:00:00', '2015-07-09T19:00:00');
    $mes = print_r($result, true);
    echo "<h2>Get Message statistics: {$mes}</h2>";
    
    $result = $devinoSMS->getInbox('2015-07-09T09:00:00', '2015-07-09T19:00:00');
    $mes = print_r($result, true);
    echo "<h2>Get Message Inbox: {$mes}</h2>";

} catch (\SmsClient\DevinoSMS\Exception $e) {
    echo $e->getMessage();
}