PHP code example of astrotomic / notifynder-sender-messagebird

1. Go to this page and download the library: Download astrotomic/notifynder-sender-messagebird 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/ */

    

astrotomic / notifynder-sender-messagebird example snippets


'senders' => [
    'messagebird' => [
        'access_key' => '',
        'callbacks' => [
            'sms' => function(\Astrotomic\Notifynder\Senders\Messages\SmsMessage $message, \Fenos\Notifynder\Models\Notification $notification) {
                return $message
                    ->from(...)
                    ->to(...)
                    ->body($notification->getText());
            },
            'voice' => function(\Astrotomic\Notifynder\Senders\Messages\CallMessage $message, \Fenos\Notifynder\Models\Notification $notification) {
                return $message
                    ->from(...)
                    ->to(...)
                    ->body($notification->getText())
                    ->lang('en-gb')
                    ->male();
            },
        ],
        'store' => false, // wether you want to also store the notifications in database
    ],
],


namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Astrotomic\Notifynder\Senders\MessageBirdSmsSender;
use Astrotomic\Notifynder\Senders\Messages\SmsMessage;
use Astrotomic\Notifynder\Senders\MessageBirdCallSender;
use Astrotomic\Notifynder\Senders\Messages\CallMessage;
use Fenos\Notifynder\Builder\Notification;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        app('notifynder.sender')->setCallback(MessageBirdSmsSender::class, function (SmsMessage $message, Notification $notification) {
            return $message
                ->from('0123456789')
                ->to('9876543210')
                ->text($notification->getText());
        });
        
        app('notifynder.sender')->setCallback(MessageBirdCallSender::class, function (CallMessage $message, Notification $notification) {
            return $message
                ->from('0123456789')
                ->to('9876543210')
                ->lang('en-us')
                ->male()
                ->text($notification->getText());
        });
    }
}