daemon144key/zenziva-notification-channel

Zenziva SMS 通知驱动程序。

1.0.0 2019-09-22 18:55 UTC

This package is not auto-updated.

Last update: 2024-09-29 06:02:33 UTC


README

Latest Version on Packagist Software License Build Status StyleCI Total Downloads

该软件包使您能够通过 Laravel 5.3 及以上版本使用 zenziva.id 发送 SMS 通知变得容易。

内容

安装

您可以通过 composer 安装此软件包

composer require daemon144key/zenziva-notification-channel

您必须安装服务提供者并将其添加到您的 config/app.php 文件中(Laravel 5.5 及以上版本可跳过)

// config/app.php
'providers' => [
    ...
    TuxDaemon\ZenzivaNotificationChannel\ZenzivaServiceProvider::class,
],

此外,您还可以在 config/app.php 中添加相关外观

// config/app.php
'aliases' => [
    ...
    'ZenzivaClient' => TuxDaemon\ZenzivaNotificationChannel\Facades\ZenzivaFacade::class,
],

设置 zenziva-notification-channel 服务

将您的 Zenziva 账户用户密钥和密码添加到 config/services.php

// config/services.php
...
'zenziva' => [
    'userkey' => env('ZENZIVA_SMS_CLIENT_USERKEY', ''),
    'passkey' => env('ZENZIVA_SMS_CLIENT_PASSKEY', ''),
    'masking' => env('ZENZIVA_SMS_CLIENT_MASKING', false)
],
...

使用

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

use Illuminate\Notifications\Notification;
use TuxDaemon\ZenzivaNotificationChannel\ZenzivaMessage;
use TuxDaemon\ZenzivaNotificationChannel\ZenzivaChannel;

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

    public function toZenziva($notifiable)
    {
        return ZenzivaMessage::create("Your order had created!");
    }
}

或从外观调用函数

use ZenzivaClient;

class Something
{
    public function send($to, $msg)
    {
        return ZenzivaClient::send("081234567890", "hello world");
    }

    public function checkBalance()
    {
        return ZenzivaClient::checkBalance();
    }
}

或从 CLI artisan 命令中调用

$ php artisan zenziva:send 081234567890 "hello world"
$ php artisan zenziva:checkbalance

变更日志

有关最近更改的更多信息,请参阅 CHANGELOG

测试

$ composer test

安全

如果您发现任何安全相关的问题,请使用问题跟踪器。

贡献

有关详细信息,请参阅 CONTRIBUTING

许可证

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