evidencefrank/clickatell

Clickatell通知驱动

0.1.5 2021-07-26 09:01 UTC

This package is auto-updated.

Last update: 2024-09-26 20:04:09 UTC


README

此包使得使用Laravel 5.5+、6.x、7.x和8.x通过clickatell.com发送通知变得简单。

内容

安装

您可以通过composer安装此包

composer require evidencefrank/clickatell

设置clickatell服务

将您的Clickatell用户名、密码和API标识符添加到您的config/services.php

// config/services.php
...
'clickatell' => [
    'user'  => env('CLICKATELL_USER'),
    'pass' => env('CLICKATELL_PASS'),
    'api_id' => env('CLICKATELL_API_ID'),
],
...

使用

为了将Clickatell通知路由到正确的电话号码,在您的通知实体上定义一个routeNotificationForClickatell方法

class User extends Authenticatable
{
    use Notifiable;

    /**
     * Route notifications for the Nexmo channel.
     *
     * @param  \Illuminate\Notifications\Notification  $notification
     * @return string
     */
    public function routeNotificationForClickatell($notification)
    {
        return $this->phone_number; 
    }
}

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

use Illuminate\Notifications\Notification;
use NotificationChannels\Clickatell\ClickatellMessage;
use NotificationChannels\Clickatell\ClickatellChannel;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [ClickatellChannel::class];
    }

    public function toClickatell($notifiable)
    {
        return (new ClickatellMessage())
            ->content("Your {$notifiable->service} account was approved!");
    }
}

可用方法

待办事项

变更日志

有关最近更改的更多信息,请参阅变更日志

测试

$ composer test

安全性

如果您发现任何安全问题,请通过电子邮件evidencefrank.mandizvidza@gmail.com联系,而不是使用问题跟踪器。

贡献

有关详细信息,请参阅贡献指南

致谢

许可证

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