PHP code example of kirimi / laravel-kirimi

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

    

kirimi / laravel-kirimi example snippets


use Kirimi\Laravel\Facades\Kirimi;

// Send a regular message
Kirimi::sendMessage('device_001', '628123456789', 'Hello from Kirimi!');

// Send a message with media
Kirimi::sendMessage('device_001', '628123456789', 'Check this out!', 'https://example.com/image.jpg');

// Send fast (no typing effect)
Kirimi::sendMessageFast('device_001', '628123456789', 'Quick message');

// Broadcast to many recipients (numbers is an array, label is 'Hi there!']);

// Generate OTP
Kirimi::generateOTP('device_001', '628123456789', ['otp_length' => 6]);

// Send OTP v2 (whatsapp | device | waba_user)
Kirimi::sendOtpV2('628123456789', ['method' => 'whatsapp']);
Kirimi::sendOtpV2('628123456789', ['method' => 'device', 'device_id' => 'device_001', 'custom_message' => 'Your code is {{otp}}']);
Kirimi::sendOtpV2('628123456789', ['method' => 'waba_user', 'waba_id' => 'waba_001', 'template_name' => 'otp_login']);

// Save a contact (nama + nomor)
Kirimi::saveContact('Budi', '628123456789');

// Devices
$devices = Kirimi::listDevices();
$status = Kirimi::deviceStatus('device_001');
$newDevice = Kirimi::createDevice(1);

// Packages & deposits
$packages = Kirimi::listPackages();
$deposit = Kirimi::createDeposit(50000);
$status = Kirimi::depositStatus($deposit['ref']);

use Illuminate\Notifications\Notification;
use Kirimi\Laravel\Messages\KirimiMessage;

class OrderPaid extends Notification
{
    public function __construct(private string $orderNumber) {}

    public function via($notifiable): array
    {
        return ['kirimi'];
    }

    public function toKirimi($notifiable): KirimiMessage
    {
        return (new KirimiMessage)
            ->to($notifiable->phone)
            ->device($notifiable->kirimi_device_id)  // optional, falls back to config default
            ->message("Order #{$this->orderNumber} has been paid. Thank you!");
    }
}

public function toKirimi($notifiable): KirimiMessage
{
    return KirimiMessage::create('Your invoice is ready.')
        ->to($notifiable->phone)
        ->mediaUrl('https://example.com/invoice.pdf');
}

return KirimiMessage::create('OTP: 123456')->to($notifiable->phone)->quick();

return KirimiMessage::create()
    ->to($notifiable->phone)
    ->waba()
    ->wabaId('waba_001')            // optional, falls back to config default
    ->template('order_update')
    ->variables(['A1', 'B2'])
    ->header(['type' => 'text', 'text' => 'Order update']);

return KirimiMessage::create('Flash sale starts now!')
    ->device('device_001')
    ->broadcast('flash-sale', ['628123456789', '628987654321']);

return KirimiMessage::create()
    ->device('device_001')
    ->nama('Budi')
    ->nomor('628123456789');

$user->notify(new OrderPaid($order->number));
// or
Notification::send($users, new OrderPaid($order->number));

kirimi()->sendMessage('device_001', '628123456789', 'Hello!');
kirimi()->generateOTP('device_001', '628123456789');
bash
php artisan vendor:publish --tag=kirimi-config
bash
# Basic
php artisan kirimi:send 628123456789 "Hello from CLI"

# With specific device
php artisan kirimi:send 628123456789 "Hello" --device=device_001

# With media URL
php artisan kirimi:send 628123456789 "Check this" --media=https://example.com/img.jpg

# Fast mode
php artisan kirimi:send 628123456789 "Quick hello" --fast