PHP code example of subitosms / subitosms-php

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

    

subitosms / subitosms-php example snippets




ubitoSMS\Client;

$sms = new Client('la-tua-username', 'la-tua-password');

$shipmentId = $sms->send(
    'MIOBRAND',
    '+393351234567',
    'Ciao da SubitoSMS!'
);

echo "Spedizione: {$shipmentId}";

$shipmentId = $sms->send(
    'MIOBRAND',
    ['+393351234567', '+393331234567'],
    'Promemoria appuntamento domani alle 10:00.'
);

$shipmentId = $sms->send(
    'MIOBRAND',
    '+393351234567',
    'Messaggio di prova',
    true,
    15
);

$credit = $sms->balance();
$creditWithForeign = $sms->balance(true);

foreach ($sms->status($shipmentId) as $delivery) {
    printf(
        "%s — stato %d: %s%s",
        $delivery->getDestination(),
        $delivery->getStatus(),
        $delivery->getDescription(),
        PHP_EOL
    );

    if ($delivery->isTerminal()) {
        // Stati terminali: -100, -50, 1, 16.
    }
}

use SubitoSMS\Exception\ApiException;
use SubitoSMS\Exception\TransportException;

try {
    $shipmentId = $sms->send('MIOBRAND', '+393351234567', 'Ciao');
} catch (TransportException $e) {
    // Problema di rete/HTTPS: l'invio potrebbe non essere arrivato al gateway.
} catch (ApiException $e) {
    // Risposta del gateway non valida o non accettata.
}
bash
composer