Skip to content
This repository has been archived by the owner on Jul 12, 2021. It is now read-only.
/ smsbot-sdk Public archive

An easy-to-use Software Development Kit made in PHP 7.4 for communicating with the Smsbot API.

License

Notifications You must be signed in to change notification settings

adresser/smsbot-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smsbot-php-sdk

Actions Status LICENSE Packagist

🚀An easy-to-use Software Development Kit made in PHP for communicating with the Smsbot API.

Installation

Download the repository or get it via Composer (recommended):

$ composer require adresser/smsbot-sdk

Versions

This package uses semver.

Supported PHP Versions

This library supports the following PHP implementations:

  • PHP 7.2
  • PHP 7.3
  • PHP 7.4

Quickstart

  • Sign up on the smsbot platform
  • Get your authentication key (find it on Settings section)
  • To send SMSs using your device, connect the device and get the device id and the SIM id
  • To send SMSs using the HTTP gateway, make a sender ID (go on Sender ids section)

Include the vendor/autoload.php file to load all the library classes.

The Smsbot facade provides an ingress to the SDK. However, you can use the internal classes at your convenience.

Valid phone number pattern

The phone number must follow this pattern:

+(prefix)(number) // es: +13334445566

Send an SMS through the HTTP Gateway

Notes: To send a bulk sms add more destination using the pushDestination method.

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); 

Send an SMS through the registered device

Notes: To send a bulk sms add more destination using the pushDestination method.

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); 

Generate an OTP

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"; 
} 

Using a custom http client

The custom http client must implement the Psr\Http\Client\ClientInterface.

$customHttpClient = new CustomHttpClient(); 

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

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

Getting help

For any question or problem, we suggest to open an issue!

About

An easy-to-use Software Development Kit made in PHP 7.4 for communicating with the Smsbot API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages