PHP Classes

PHP SMS Gateway Integration: Send SMS messages using different providers

Recommend this page to a friend!
  Info   View files Documentation   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-12-27 (5 months ago) RSS 2.0 feedNot enough user ratingsTotal: 75 All time: 10,178 This week: 74Up
Version License PHP version Categories
php-sms-gateways 1.0MIT/X Consortium ...8Wireless and Mobile, Libraries, Web s..., C..., P...
Description 

Authors

Ujah Chigozie
Nanoblock Technology


Contributor

This package can send SMS messages using different providers.

It provides a gateway class that implements functions to set details of SMS messages and send the messages using separate provider client classes.

The package also provides several provider client classes to integrate with provides like Vonage or ClickSend.

Picture of Ujah Chigozie peter
  Performance   Level  
Name: Ujah Chigozie peter <contact>
Classes: 25 packages by
Country: Nigeria Nigeria
Age: 33
All time rank: 201910 in Nigeria Nigeria
Week rank: 15 Up2 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 11x

Documentation

PHP SMS GATEWAYS

PHP class for sms gateways, using same codebase and implementation to send sms in Vonage & ClickSend sms gateways.

AVAILABLE SMS PROVIDERS

  • Vonage: To use Vonage as provider, install the library `composer require vonage/client`
  • ClickSend To use ClickSend as provider, install the library `composer require clicksend/clicksend-php`

Installation Guide via Composer:

composer require nanoblocktech/php-sms-gateways

Usages

Initialize classes

use \Luminova\ExtraUtils\Sms\Gateway;
use \Luminova\ExtraUtils\Sms\Providers\Vonage;
use \Luminova\ExtraUtils\Sms\Providers\ClickSend;
use \Luminova\ExtraUtils\Sms\Exceptions\SmsException;

Initialize SMS Client using Vonage

use Luminova\ExtraUtils\Sms\Providers\Vonage;

$client = new Vonage("KEY", "SECRETE");

Initialize SMS Client using ClickSend

use Luminova\ExtraUtils\Sms\Providers\ClickSend;

$client = new ClickSend("USERNAME", "KEY");

Initialize SMS gateway

$gateway = new Gateway($client);

$gateway->setPhone('000000000');
$gateway->setFrom('000000000');
$gateway->setMessage('Hello your verification code is 1234');
try {
    if($gateway->send()){
        echo "Message sent successfully";
    }else{
        $response = $gateway->getResponse();
        echo $response->getError();
    }
} catch (SmsException $e){
    echo $e->getMessage();
}

Send sms using modem serial port

use Luminova\ExtraUtils\Sms\SerialGateway;
try{
    $serial = new SerialGateway('COM4', 'en_US');
    $serial->send('000000000', 'Hello your verification code is 1234', function($data){
        echo "Message sent successfully";
    });
} catch (SmsException $e){
    echo $e->getMessage();
}

Configuring your serial

use Luminova\ExtraUtils\Sms\SerialGateway;
$to = '9999999999';
$message = 'Hello your verification code is 1234';

try{
    $serial = new SerialGateway('COM4', 'en_US');
    $serial->setBaudRate(9600);
    $serial->setParity('none');
    $serial->setCharacterLength(8);
    $serial->setStopBits(1);
    $serial->setFlowControl('none');
    if($serial->openDevice()){
        $serial->sendMessage("AT+CMGF=1\n\r"); 
        $serial->sendMessage("AT+cmgs=\"{$to}\"\n\r");
        $serial->sendMessage("{$message}\n\r");
        $serial->sendMessage(chr(26));

        sleep(7);

        $read = $serial->readPort(0);
        $serial->closeDevice();
        echo "Message was sent successfully";
    }
} catch (SmsException $e){
    echo $e->getMessage();
}

Response methods

 $response = $gateway->getResponse();

/
 * Get response status 
*/
$response->getStatus();

/
 * Get gateways response status 
*/
$response->getOriginalStatus();

/
 * Check if sms message was sent
*/
$response->isSuccess();

/
 * Get api response body
*/
$response->getContent();

/
 * Get error if any 
*/
$response->getError();

  Files folder image Files  
File Role Description
Files folder imagesrc (3 files, 4 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageExceptions (1 file)
Files folder imageInterface (1 file)
Files folder imageProviders (2 files)
Files folder imageSurface (1 file)
  Plain text file Gateway.php Class Class source
  Plain text file Response.php Class Class source
  Plain text file SerialGateway.php Class Class source

  Files folder image Files  /  src  /  Exceptions  
File Role Description
  Plain text file SmsException.php Class Class source

  Files folder image Files  /  src  /  Interface  
File Role Description
  Plain text file ProviderInterface.php Class Class source

  Files folder image Files  /  src  /  Providers  
File Role Description
  Plain text file ClickSend.php Class Class source
  Plain text file Vonage.php Class Class source

  Files folder image Files  /  src  /  Surface  
File Role Description
  Plain text file MessageSurface.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:75
This week:0
All time:10,178
This week:74Up