PHP code example of glushkovds / php-smpp

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

    

glushkovds / php-smpp example snippets



vice = new \PhpSmpp\Service\Sender(['smschost.net'], 'login', 'pass');
$smsId = $service->send(79001001010, 'Hello world!', 'Sender');


vice = new \PhpSmpp\Service\Listener(['smschost.net'], 'login', 'pass');
$service->listen(function (\PhpSmpp\Pdu\Sm $sm) {
    var_dump($sm->msgId);
    if ($sm instanceof \PhpSmpp\Pdu\DeliverReceiptSm) {
        var_dump($sm->state);
        var_dump($sm->state == \PhpSmpp\SMPP::STATE_DELIVERED);
        // do some job with delivery receipt
    } else {
        echo 'not receipt';
    }
});


vice = new \PhpSmpp\Service\Sender(['smschost.net'], 'login', 'pass');
$smsId = $service->sendUSSD(79001001010, 'Hello world!', 'Sender', []);



$service = new \PhpSmpp\Service\Listener(['smschost.net'], 'login', 'pass');
$service->listen(function (\PhpSmpp\Pdu\Pdu $pdu) {
    var_dump($pdu->id);
    var_dump($pdu->sequence);
    if ($pdu instanceof \PhpSmpp\Pdu\Ussd) {
        var_dump($pdu->status);
        var_dump($pdu->source->value);
        var_dump($pdu->destination->value);
        var_dump($pdu->message);
        // do some job with ussd
    }
});



ice = new \PhpSmpp\Service\Sender(['smschost.net'], 'login', 'pass');
$service->client->setTransport(new \PhpSmpp\Transport\FakeTransport());
$smsId = $service->send(79001001010, 'Hello world!', 'Sender');
bash
composer 
SmppClient::$sms_null_terminate_octetstrings = false;