Whatsapp Cloud API 的 Laravel 通知频道
This package makes it easy to send notifications using WhatsApp Cloud API with Laravel.
This package uses the whatsapp-cloud-api library that will allow you to send messages via the WhatsApp Cloud API from any type of project and framework written in PHP.
You can install the package via composer:
composer require netflie/laravel-notification-whatsappCreate a new Meta application and get your Whatsapp application token and phone number id following the "Get Started" guide. Place them inside your .env file. To load them, add this to your config/services.php file:
[
'from-phone-number-id' => env('WHATSAPP_FROM_PHONE_NUMBER_ID'),
'token' => env('WHATSAPP_TOKEN'),
],
];The Whatsapp API only allows you to start conversations if you send a template message. This means that you will only be able to send template notifications from this package.
Whatsapp forces you to configure your templates before using them. You can learn how to configure your templates by following Meta's official guide on "How to create templates".
A template is divided into 4 sections: header, body, footer and buttons. The header, body and buttons accept variables. The footer doesn't accept variables. You can only send variables from this package for the header and body.
You have available several components that can be used to add context (variables) to your templates. The different components can be created with the component factory:
name('sample_movie_ticket_confirmation') // Name of your configured template
->header(Component::image('https://lumiere-a.akamaihd.net/v1/images/image_c671e2ee.jpeg'))
->body(Component::text('Star Wars'))
->body(Component::dateTime(new \DateTimeImmutable))
->body(Component::text('Star Wars'))
->body(Component::text('5'))
->buttons(Component::quickReplyButton(['Thanks for your reply!']))
->buttons(Component::urlButton(['reply/01234'])) // List of url suffixes
->to('34676010101');
}
}You can only send a text message after you've send a template and the user responded.
message('Hello, this is a test message')
->to('34676010101');
}
}Please see CHANGELOG for more information what has changed recently.
$ composer testIf you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.
暂无开放 Issues,或尚未同步最近议题。