mahdigraph/laravel-sms

PHP SMS 驱动集成包

v1.0.1 2022-06-22 15:42 UTC

This package is auto-updated.

Last update: 2024-09-30 02:02:52 UTC


README

Laravel SMS

Laravel SMS 集成包

Software License Latest Version on Packagist Total Downloads on Packagist Maintainability StyleCI Quality Score

这是一个用于 SMS 集成的 Laravel 包。此包支持 Laravel 5.8+

此包支持多个驱动程序,如果您在以下列表(以下列表)中找不到它们,您可以创建自定义驱动程序。

目录列表

可用驱动程序列表

  • ippanel ✔️
  • 其他正在路上。

通过创建 pull requests 来帮助我添加以下网关

安装

通过 Composer

$ composer require mahdigraph/laravel-sms

配置

如果您使用的是 Laravel 5.5 或更高版本,则无需添加提供者和别名。(跳到 b)

a. 在您的 config/app.php 文件中添加以下两行。

// In your providers array.
'providers' => [
    ...
    \Metti\LaravelSms\LaravelSMSServiceProvider::class,
],

// In your aliases array.
'aliases' => [
    ...
    'SendSMS' => \Metti\LaravelSms\Facade\SendSMS::class,
],

b. 然后,运行 php artisan vendor:publish 以在您的配置目录中发布 config/sms.php 文件。

在配置文件中,您可以设置用于所有 SMS 请求的默认驱动程序。但是,您也可以在运行时更改驱动程序。

选择您要在应用程序中使用的 SMS 提供商。然后将其设置为默认驱动程序,这样您就无需在各个地方指定它。但是,您也可以在项目中使用多个 SMS 提供商。

// Eg. if you want to use ippanel.
'default' => 'ippanel',

然后在驱动程序数组中填写该驱动程序的凭证。

'drivers' => [
    'ippanel' => [
        // Fill in the credentials here.
        'key' => '00000000-0000-0000-0000-000000000000', // API Key
        'originator' => '+9890000', // Sender Number
        'patterns' => [ // patterns only if you want to use them.
            'contact' => [ // pattern name
                'pattern_code' => 'abcd-efgh-ijkl-mnop', // pattern code from your sms provider
                'values' => [ // values only if you want to set default values for your patterns.
                    'support_phone' => '021-123456789'
                ]
            ]
        ] 
    ],
    ...
]

如何使用

// Sending Text Messages
SendSMS::textMessage('Hey You :)')
    ->recipients(['09121234567','09121234568'])
    ->send();

// Sending Pattern Messages
SendSMS::via('ippanel')
    ->patternMessage('contact',['support_phone' => '021-123456789'])
    ->recipients('09121234567')
    ->send();

安全

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

鸣谢

许可协议

MIT 许可证 (MIT)。