1. Go to this page and download the library: Download inovanti-bank/messaging 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/ */
use InovantiBank\Messaging\Services\MessageService;
use InovantiBank\Messaging\Services\TwilioSmsService;
use InovantiBank\Messaging\Providers\TwilioProvider;
use InovantiBank\Messaging\DTOs\MessageData;
use Illuminate\Events\Dispatcher;
$twilioProvider = new TwilioProvider(
env('TWILIO_ACCOUNT_SID'),
env('TWILIO_AUTH_TOKEN')
);
$smsService = new TwilioSmsService($twilioProvider);
$messageService = new MessageService([
'sms' => $smsService,
], new Dispatcher());
$messageData = new MessageData(
type: 'sms',
to: '+5511987654321',
from: env('TWILIO_SMS_FROM'),
content: 'Mensagem SMS de teste via Twilio.'
);
// Enviando mensagem
$response = $messageService->send($messageData);
print_r($response);
use InovantiBank\Messaging\Services\MessageService;
use InovantiBank\Messaging\Services\TwilioWhatsAppService;
use InovantiBank\Messaging\Providers\TwilioProvider;
use InovantiBank\Messaging\DTOs\MessageData;
use Illuminate\Events\Dispatcher;
$twilioProvider = new TwilioProvider(
env('TWILIO_ACCOUNT_SID'),
env('TWILIO_AUTH_TOKEN')
);
$whatsappService = new TwilioWhatsAppService($twilioProvider);
$messageService = new MessageService([
'whatsapp' => $whatsappService,
], new Dispatcher());
$messageData = new MessageData(
type: 'whatsapp',
to: '+5511987654321',
from: env('TWILIO_WHATSAPP_FROM'),
content: 'Mensagem de teste via WhatsApp Twilio.'
);
$response = $messageService->send($messageData);
print_r($response);
use InovantiBank\Messaging\Services\MessageService;
use InovantiBank\Messaging\Services\SendGridEmailService;
use InovantiBank\Messaging\Providers\SendGridProvider;
use InovantiBank\Messaging\DTOs\MessageData;
use Illuminate\Events\Dispatcher;
$sendGridProvider = new SendGridProvider(env('SENDGRID_API_KEY'));
$emailService = new SendGridEmailService($sendGridProvider);
$messageService = new MessageService([
'email' => $emailService,
], new Dispatcher());
$messageData = new MessageData(
type: 'email',
to: '[email protected]',
from: env('SENDGRID_FROM_EMAIL'),
content: 'Este é um e-mail de teste enviado via SendGrid.',
metadata: ['subject' => 'Teste de E-mail via SendGrid']
);
$response = $messageService->send($messageData);
print_r($response);