PHP code example of kevinpurwito / laravel-zenziva

1. Go to this page and download the library: Download kevinpurwito/laravel-zenziva 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/ */

    

kevinpurwito / laravel-zenziva example snippets


[
    'type' => strtolower(env('KP_ZENZIVA_TYPE', 'console')), // gsm or console

    'userkey' => env('KP_ZENZIVA_USERKEY'),
    
    'passkey' => env('KP_ZENZIVA_PASSKEY'),
];

[
    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');

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"
//    }
}

text
KP_ZENZIVA_TYPE=console
KP_ZENZIVA_USERKEY=user
KP_ZENZIVA_PASSKEY=secret