Laravel Zenziva is a package that integrates Zenziva for Laravel.
You can install the package via composer:
composer require kevinpurwito/laravel-zenziva
The vendor:publish
command will publish a file named kp_zenziva.php
within your laravel project config
folder config/kp_zenziva.php
.
Published Config File Contents
[
'type' => strtolower(env('KP_ZENZIVA_TYPE', 'console')), // gsm or console
'userkey' => env('KP_ZENZIVA_USERKEY'),
'passkey' => env('KP_ZENZIVA_PASSKEY'),
];
Alternatively you can ignore the above publish command and add this following variables to your .env
file.
KP_ZENZIVA_TYPE=console
KP_ZENZIVA_USERKEY=user
KP_ZENZIVA_PASSKEY=secret
If you're using Laravel 5.5+ you don't need to manually add the service provider or facade. This will be
Auto-Discovered. For all versions of Laravel below 5.5, you must manually add the ServiceProvider & Facade to the
appropriate arrays within your Laravel project config/app.php
[
Kevinpurwito\LaravelZenziva\ZenzivaServiceProvider::class,
];
[
'Zenziva' => Kevinpurwito\LaravelZenziva\ZenzivaFacade::class,
];
use Kevinpurwito\LaravelZenziva\ZenzivaFacade as Zenziva;
// returns the balance/credit that you have
Zenziva::getBalance();
// returns the balance/credit that you have, including the expiry date of the balance
Zenziva::balance();
// send SMS
Zenziva::sendSms('+62xxx', 'message');
// send Whatsapp message
Zenziva::sendWa('+62xxx', 'message');
// send Whatsapp file from URL, including a caption/message
Zenziva::sendWaFile('+62xxx', 'message', 'https://image.com/image.png');
// GSM only feature to send SMS OTP
Zenziva::sendOtp('+62xxx', '123xxx');
// Console only feature to send voice message
Zenziva::sendWa('+62xxx', 'message');
Accepted file types for
sendWaFile()
are: .doc .pdf .xls .xlsx .csv .gif .jpg .mp4 .mp3
use Kevinpurwito\LaravelZenziva\ZenzivaFacade as Zenziva;
// returns the balance/credit that you have
$response = Zenziva::sendWa('+62xxx', 'message');
if ($response->getStatusCode() == 201) {
// if you want to check the response body, such as `messageId` you can do this:
$content = json_decode($response->getBody()->getContents());
dump($content);
// {
// "messageId":"157365",
// "to":"+62xxx",
// "status":"1",
// "text":"Success"
// }
}
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email kevin.purwito@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the PHP Package Boilerplate by Beyond Code with some modifications inspired from PHP Package Skeleton by spatie.