PHP code example of didimo / sms

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

    

didimo / sms example snippets




use Didimo\Sms\Sms;

$sms = new Sms('USER','PASSWORD');
//Enviar sms desde producción
$sms->setEnvironment('live');

$response = $sms->createMessage('Prueba','34666666666','Esto es una prueba');
if($response->Status == 200) {
    if($response->ResponseCode == 0 && $response->ResponseMessage == 'Operation Success') {
        echo 'Enviado correctamnete';
    }
    else {
        echo 'Error, no se pudo enviar el sms';
    }
}
else {
    print_r($response);
}


$sms->setEnvironment('test');

    $now = date('Y-m-d H:i:s');
    $newdate = date('Y-m-d\TH:i:s', strtotime('+1 hour', strtotime($now)));
    $sms->createMessage('Prueba','34666666666','Mensaje con scheduler',$newdate);

stdClass Object
(
    [ResponseCode] => 0
    [ResponseMessage] => Operation Success
    [Id] => cb303162-ee35-4357-98xc-90025a69da00
    [Status] => 200
)



use Didimo\Sms\Sms;

$sms = new Sms('USER','PASSWORD');
//Enviar sms desde producción
$sms->setEnvironment('live');

$messages = ['0034666666666' => 'Mensaje personalizado', '0034777777777' => 'Otro mensaje personalizado'];
$response = $sms->createSend('Prueba',$messages);

if($response->Status == 200) {
    if($response->ResponseCode == 0 && $response->ResponseMessage == 'Operation Success') {
        echo 'Enviado correctamente';
    }
    else {
        echo 'Error, no se pudo enviar el sms'.;

    }
}
else {
    print_r($response);
}


stdClass Object
(
    [ResponseCode] => 0
    [ResponseMessage] => Operation Success
    [Output] => Array
        (
            [0] => stdClass Object
                (
                    [ResponseCode] => 0
                    [ResponseMessage] => Operation Success
                    [Id] => b9d4e771-82e7-40b0-a338-26653a4scf3h
                    [Mobile] => 0034666666666
                    [Text] => Mensaje personalizado
                )

            [1] => stdClass Object
                (
                    [ResponseCode] => 0
                    [ResponseMessage] => Operation Success
                    [Id] => 51423261-0a9c-41c6-8139-a097304aa240
                    [Mobile] => 0034777777777
                    [Text] => Otro mensaje personalizado
                )

        )
    [Status] => 200
)




use Didimo\Sms\Sms;

$sms = new Sms('USER','PASSWORD');

//Consultar en producción
$sms->setEnvironment('live');

$id='c366018b-97ba-4a78-8183-0d975bd2620b';
$response = $sms->getMessageStatus($id);
if($response->Status == 200) {
    if($response->ResponseCode == 0 && $response->ResponseMessage == 'Operation Success') {
        echo "Estatus: ".$response->StatusDescription;
    }
    else {
        echo 'Error al obtener estatus';
    }
}
else{
    print_r($response);
}



stdClass Object
(
    [ResponseCode] => 0
    [ResponseMessage] => Operation Success
    [StatusCode] => PT0001
    [StatusDescription] => Pendiente - En Bandeja de Salida
    [Status] => 200

)




use Didimo\Sms\Sms;

$sms = new Sms('USER','PASSWORD');

//Consultar en producción
$sms->setEnvironment('live');

$response = $sms->getCredits();

if($response->Status == 200) {
    if($response->ResponseCode == 0 && $response->ResponseMessage == 'Operation Success') {
        echo "Total saldo: ".$response->Credits;
    }
    else {
        echo 'Error al obtener saldo';
    }
}
else {
    print_r($response);
}


stdClass Object
(
    [ResponseCode] => 0
    [ResponseMessage] => Operation Success
    [Credits] => 8000
    [Status] => 200
)