randhipp / wafvel-notification

Laravel 通知通道 - WhatsApp 聊天 - 使用 POST 请求到 wafvel.com API

dev-main 2020-12-29 14:56 UTC

This package is auto-updated.

Last update: 2024-09-29 05:49:44 UTC


README

此包使您能够通过 Laravel 通知系统轻松发送 WhatsApp。

安装

您可以通过 composer 安装此包

composer require randhipp/wafvel-notification

使用方法

现在您可以在通知内的 via() 方法中使用此通道

use Wafvel\Notification\WafvelChannel;
use Wafvel\Notification\WafvelMessage;
use Illuminate\Notifications\Notification;

class ProjectCreated extends Notification
{
    protected $data;

    public function __construct($data = null)
    {
        $this->data = $data;
    }

    public function via($notifiable)
    {
        return [WafvelChannel::class];
    }

    public function toWafvel($notifiable)
    {
        $message = $this->data ?? "Your Chat Message\nNew Line";

        return WafvelMessage::create()
            ->token('') // bot token, if not specified will using env value WAFVEL_BOT_TOKEN
            ->phone('628123456789') // format : 628123456789 => {countrycode:id}{phonenumber_without_leading_zero:08123456789}
            ->message($message);
    }
}

可用方法

  • token(''):接受来自 wafvel.com 的令牌 - 免费注册!
  • phone(''):接受接收者的电话号码
  • message(''):接受消息的字符串值

安全

如果您发现任何安全相关的问题,请通过电子邮件发送给 randhi.pp@gmail.com,而不是使用问题跟踪器。

致谢

此项目基于 Marcel Pociot 的 Webhook 通知通道 Marcel Pociot

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件