PHP code example of smsgate / client

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

    

smsgate / client example snippets


//use composer's autoload
eal URL for bulk gate
$gate = new SMSGate\Client('http://localhost:9000/bulk_server');

$sms = new SMSGate\SMSRequest;
$sms    ->setType(SMSGate\Client::TYPE_TEXT)
        ->setAuthUsername('test')
        ->setAuthPassword('test')
        ->setSender('Test Sender')
        ->setReceiver('41587000201')
        ->setText('Hello there!')
        ////make sure to set the real URL for your webhook handler
        ->setDlrUrl('http://localhost:8000/dlr.php')
        ->setDlrMask(SMSGate\Client::DLR_MASK_STANDARD);
try {
    $response = $gate->send($sms);
} catch (\Exception $exc) {
    echo "Error sending SMS with code: " . $exc->getCode() . " and message: " . $exc->getMessage();
    exit;
}

echo "SMS sent with ID: " . $response->msgId . " and num of parts: " . $response->numParts;

//use composer's autoload
nt('');

$dlr = $gate->parseDeliveryReport();
if(!isset($dlr)){
    error_log("Cannot parse DLR from the request");
    exit;
}

error_log("Received DLR: " . json_encode($dlr));