Zenziva SMS Online Gateway Library based on Zenziva Documentation
- PHP with Curl Extension Support
- Zenziva Account
Recommended install via composer
composer require faytranevozter/zenziva-lib
All example below is placed under autoload composer
require 'vendor/autoload.php';
use Faytranevozter\Zenziva\Sms;
// your code here ...
$sms = new Sms('faytranevozter', '123456');
// or
$sms = new Sms();
$sms->username('faytranevozter'); // chainable
$sms->password('123456'); // chainable
// send sms
$sms->send('089765432123', 'Helaw!'); // send(number, text, otp)
Default type is reguler
if 3rd parameter not set.
$sms = new Sms('faytranevozter', '123456', 'masking');
$sms->send('089765432123', 'Helaw! this is masking sms');
// or
$sms = new Sms('faytranevozter', '123456');
$sms->type('masking'); // chainable
// send sms
$sms->send('089765432123', 'Helaw! this is masking sms'); // send(number, text, otp)
Default type is reguler
if 3rd parameter not set.
$sms = new Sms('faytranevozter', '123456', 'sms_center');
$sms->subdomain('mysubdomain'); // chainable, [required for sms_center]
$sms->send('089765432123', 'Helaw! this is from sms_center');
// or
$sms = new Sms('faytranevozter', '123456');
$sms->type('sms_center'); // chainable
$sms->subdomain('mysubdomain'); // chainable, [required for sms_center]
// send sms
$sms->send('089765432123', 'Helaw! this is from sms_center'); // send(number, text, otp)
Default type is reguler
if 3rd parameter not set.
Zenziva now apply special treatment for SMS OTP. See #Zenziva Docs
Untuk mengirim SMS OTP, wajib menambahkan parameter type=otp
$sms = new Sms('faytranevozter', '123456', 'masking');
$sms->send('089765432123', 'Helaw! this is masking sms', TRUE);
// or
$sms = new Sms('faytranevozter', '123456');
$sms->otp(TRUE); // chainable
// send sms
$sms->send('089765432123', 'Helaw! this is masking sms'); // send(number, text, otp)
$sms = new Sms();
$sms->username('faytranevozter')
->password('123456')
->type('masking')
->to('089765432123')
->message('Helaw!')
->send();
$sms = new Sms('faytranevozter', '123456');
$is_send = $sms->send('089765432123', 'Helaw! this is my sms');
if ($is_send) {
echo "Sms sent!";
} else {
echo "Uh-oh! Failed to send sms";
}
$sms = new Sms('faytranevozter', '123456');
$sms->send('089765432123', 'Helaw! this is my sms');
$sms->send('082341561273', 'Helaw! this is my second sms');
// get all response
print_r($sms->responses()); // return array of response
// get last response
print_r($sms->last_response()); // return last response
$sms = new Sms('faytranevozter', '123456');
$sms->send('089765432123', 'Helaw! this is my sms');
$sms->send('082341561273', 'Helaw! this is my second sms');
// get all error
print_r($sms->errors()); // return array of error
// get last error
print_r($sms->last_error()); // return last error
Creating library Zenziva.php
use Faytranevozter\Zenziva\Sms;
class Zenziva extends Sms {
function __construct($params=array()) {
parent::__construct(...$params);
}
}
Load Zenziva library from controller
...
$this->load->library('Zenziva', ['faytranevozter', '123456', 'reguler']);
$this->zenziva->send('089765432123', 'Helaw! this is my sms');
...
Fahrur Rifai fahrur.dev
Twitter @faytranevozter
MIT License