PHP code example of adresser / smsbot-sdk

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

    

adresser / smsbot-sdk example snippets


use Adresser\Smsbot\Sms;
use Adresser\Smsbot\Facade\Smsbot;

Smsbot::setAuthenticationKey('set the authentication key'); 

$clientFactory = Smsbot::getSmsClientFactory(); 

$client = $clientFactory->getClient('http'); 
$client->setSenderId('put the sender id'); 

// in future this will no longer be needed  
$client->setCountryId('put the country code'); 

$sms = new Sms('test message!'); 
$sms->pushDestination('+39xxxxxxxxxx'); 

$client->send($sms); 

use Adresser\Smsbot\Sms;
use Adresser\Smsbot\Facade\Smsbot;

Smsbot::setAuthenticationKey('set the authentication key'); 

$clientFactory = Smsbot::getSmsClientFactory(); 
$client = $clientFactory->getClient('device');

$client->setDeviceId('put the device id here');
$client->setSimId('put the sim id here'); 

$sms = new Sms('test message!'); 
$sms->pushDestination('+39xxxxxxxxxx'); 

$client->send($sms); 

use Adresser\Smsbot\Facade\Smsbot;

Smsbot::setAuthenticationKey('set the authentication key'); 
$factory = Smsbot::getOtpFactory(); 

$generator = $factory->getOtpGenerator(); 
$validator = $factory->getOtpValidator();  

// set the One Time Password lifetime in seconds 
$otp = $generator->generate(3600); 

// the otp will be store inside the smsbot system
if ($validator->validate($otp)) {
    echo "The OTP is valid! \n"; 
} 

$customHttpClient = new CustomHttpClient(); 

$requestDispatcher = new Adresser\Smsbot\RequestDispatcher('auth key', $customHttpClient);

// same with other types of sms clients 
$deviceSmsClient = new Adresser\Smsbot\DeviceSmsClient($requestDispatcher);