dukstra/clickatell

Clickatell通知驱动程序

v1.5.2 2021-08-13 05:51 UTC

This package is auto-updated.

Last update: 2024-09-13 13:03:19 UTC


README

本包可轻松使用Laravel 5.5+、6.x、7.x和8.x通过clickatell.com发送通知。

内容

安装

您可以通过composer安装此包

composer require dukstra/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 Dukstra\Clickatell\ClickatellMessage;
use Dukstra\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

安全

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

贡献

有关详细信息,请参阅CONTRIBUTING

致谢

许可

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