Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 78 | All time: 10,151 This week: 43![]() |
Version | License | PHP version | Categories | |||
php-sms-gateways 1.0 | MIT/X Consortium ... | 8 | Wireless and Mobile, Libraries, Web s..., C..., P... |
Description | Authors Ujah Chigozie Contributor | |
This package can send SMS messages using different providers. |
|
PHP class for sms gateways, using same codebase and implementation to send sms in Vonage & ClickSend sms gateways.
Installation Guide via Composer:
composer require nanoblocktech/php-sms-gateways
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();
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Doc. | Documentation |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.