susheelbhai/laratsapp
Composer 安装命令:
composer require susheelbhai/laratsapp
包简介
this packae can be used to send whatsapp message using some service providers api
README 文档
README
Installation
Laravel
Require this package in your composer.json and update composer. This will download the package.
composer require susheelbhai/laratsapp
Configuration
Vendor Publish
Publish config files using the following command
php artisan vendor:publish --tag="whatsapp" --force
Final Step
Add environment valriable by runnung the command
php artisan whatsapp:update_env
go to .env file and put value of the required variables
Application Guide
Import facade at the top of the class after namespace
use WhatsApp;
Create $data variable and call the facade
Text message example
$data = [
'phone' => '9999999999',
'message' => 'message content'
];
WhatsApp::sendText($data);
Text otp example
$data = [
'phone' => '9999999999',
'message' => 'otp'
];
WhatsApp::sendOTP($data);
Media message example
$data = [
'phone' => '9999999999',
'message' => 'message content',
'media_url' => 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
];
WhatsApp::sendMedia($data);
Make sure media url is available on live server and accessible publicly
You can aslo use this package with laravel notification class
add channel name whatsapp in via method. following is the example
public function via(object $notifiable): array
{
$channels = [];
if (config('mail.send_mail') == 1 && isset($notifiable->email)) {
$channels[] = 'mail';
}
if (config('whatsapp.send_msg') == 1 && isset($notifiable->phone)) {
$channels[] = 'whatsapp';
}
return $channels;
}
Now add the other method by which you want to send the message. you can use 1 or more from the following
public function toWhatsAppText($notifiable)
{
return 'Thank you for contacting '.config('app.name').'. We have received your message and will get back to you shortly.';
}
public function toWhatsAppOTP($notifiable)
{
return '223344';
}
public function toWhatsAppPdf($notifiable)
{
return [
'message' => 'Thank you for contacting '.config('app.name').'. We have received your message and will get back to you shortly.',
'media_url' => "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
];
}
public function toWhatsAppMedia($notifiable)
{
return [
'message' => 'Thank you for contacting '.config('app.name').'. We have received your message and will get back to you shortly.',
'media_url' => "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
];
}
License
This Multi Auth Package is developed by susheelbhai for personal use software licensed under the MIT license
susheelbhai/laratsapp 适用场景与选型建议
susheelbhai/laratsapp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 523 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 susheelbhai/laratsapp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 susheelbhai/laratsapp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 523
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-29