PHP code example of caherrera / laravel-notifications-infobip-omni

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

    

caherrera / laravel-notifications-infobip-omni example snippets


// config/services.php
...
    'infobip' => [
        'auth'        => env('INFOBIP_AUTH','basic'),
        'username'    => env('INFOBIP_USERNAME'),
        'password'    => env('INFOBIP_PASSWORD'),
        'baseUrl'     => env('INFOBIP_BASE_URL'),
        'apikey'      => env('INFOBIP_PUBLIC_KEY'),
        'scenarioKey' => env('INFOBIP_SCENARIO_KEY'),
    ],
...

public function routeNotificationForInfobip()
{
    return '+1234567890';
}

use App\Notifications\ExampleInfobipNotification;
use Illuminate\Support\Facades\Notification;

Notification::send($user, new ExampleInfobipNotification());

// where $user implements `Illuminate\Notifications\Notifiable` trait

use App\Notifications\ExampleInfobipNotification;

$user->notify(new ExampleInfobipNotification($invoice));



namespace App\Notifications;

use Illuminate\Notifications\Notification;
use Caherrera\Laravel\Notifications\Channels\Infobip\Omni\InfobipChannel;
use Caherrera\Laravel\Notifications\Channels\Infobip\Omni\InfobipMessage;

class ExampleInfobipNotification extends Notification
{
    public function via($notifiable)
    {
        return [InfobipChannel::class];
    }

    public function toInfobip($notifiable)
    {
        $message = new InfobipMessage();
		$message->setTemplateName("infobip_test_hsm");
		$message->setTemplateNamespace("whatsapp:hsm:it:infobip");
		$message->setTemplateData(["Jhon","Snow"]);
		$message->setLanguage("es");
        return $message;
        
    }
}



namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;
}
 php
use NotificationChannels\Infobip\InfobipChannel;
use NotificationChannels\Infobip\InfobipMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [InfobipChannel::class];
    }

    public function toInfobip($notifiable)
    {
    	$message = new InfobipMessage();
		$message->setTemplateName("infobip_test_hsm");
		$message->setTemplateNamespace("whatsapp:hsm:it:infobip");
		$message->setTemplateData(["Jhon","Snow"]);
		$message->setLanguage("es");
        return $message;
    }
}