1. Go to this page and download the library: Download phpbook/sms 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/ */
phpbook / sms example snippets
/********************************************
*
* Declare Configurations
*
* ******************************************/
//Driver connection NEXMO
\PHPBook\SMS\Configuration\SMS::setConnection('main',
(new \PHPBook\SMS\Configuration\Connection)
->setName('Main')
->setExceptionCatcher(function(String $message) {
//the PHPBook SMS does not throw exceptions, but you can take it here
//you can store $message in database or something else
})
->setDriver((new \PHPBook\SMS\Driver\NEXMO)
->setKey('key')
->setSecret('secret')
->setFrom('00000000000'))
);
//Driver connection PLIVO
\PHPBook\SMS\Configuration\SMS::setConnection('notify',
(new \PHPBook\SMS\Configuration\Connection)
->setName('Notify')
->setExceptionCatcher(function(String $message) {
//the PHPBook SMS does not throw exceptions, but you can take it here
//you can store $message in database or something else
})
->setDriver((new \PHPBook\SMS\Driver\PLIVO)
->setKey('key')
->setToken('token')
->setFrom('00000000000'))
);
//Driver connection TWILIO
\PHPBook\SMS\Configuration\SMS::setConnection('payments',
(new \PHPBook\SMS\Configuration\Connection)
->setName('Payments')
->setExceptionCatcher(function(String $message) {
//the PHPBook SMS does not throw exceptions, but you can take it here
//you can store $message in database or something else
})
->setDriver((new \PHPBook\SMS\Driver\TWILIO)
->setKey('key')
->setToken('token')
->setFrom('00000000000'))
);
//Set default connection by connection code
\PHPBook\SMS\Configuration\SMS::setDefault('main');
//Getting connections
$connections = \PHPBook\SMS\Configuration\SMS::getConnections();
foreach($connections as $code => $connection) {
$connection->getName();
$connection->getDriver();
};
//Connection code is not tain the country code with plus and are code too.
$boolean = (new \PHPBook\SMS\SMS)
->setConnectionCode('notify')
->setMessage(
(new \PHPBook\SMS\Message)
->setTo(['+5547999999999', '+5547888888888'])
->setContent('Hi Jhon')
)
->dispatch();
if ($boolean) {
//sent
};
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.