laravel-notification-channels/46elks
Composer 安装命令:
composer require laravel-notification-channels/46elks
包简介
Laravel notification channel package for 46Elks.
README 文档
README
This package makes it easy to send notifications using 46Elks with Laravel.
46Elks has a whole bunch of phone oriented services. This package takes care of:
- SMS
With more endpoints to come. Feel free to contribute.
Contents
Installation
composer require laravel-notification-channels/46elks
Setting up the 46Elks service
add the following to your config/services.php
'46elks' => [ 'username' => env('FORTY_SIX_ELKS_USERNAME'), 'password' => env('FORTY_SIX_ELKS_PASSWORD'), ],
Also remember to update your .env with correct information:
FORTY_SIX_ELKS_USERNAME=
FORTY_SIX_ELKS_PASSWORD=
You will find your username and password at https://46elks.se/account
Usage
To use this channel simply create a notification that has the following content:
use NotificationChannels\FortySixElks\FortySixElksChannel; use NotificationChannels\FortySixElks\FortySixElksSMS; public function via($notifiable) { return [FortySixElksChannel::class]; } public function to46Elks($notifiable) { return (new FortySixElksSMS()) ->line('Testsms') ->line('Olle') ->to('+46701234567') ->from('Emil') // ->flash() - Optional // ->whenDelivered(URL) - Optional // ->dontLog() - Optional // ->dry() - Optional }
Another example without the notification implementation.
use NotificationChannels\FortySixElks\FortySixElksSMS; (new FortySixElksSMS()) ->line('Testsms') ->line('Olle') ->to('+46701234567') ->from('Emil') // ->flash() - Optional // ->whenDelivered(URL) - Optional // ->dontLog() - Optional // ->dry() - Optional ->send();
Available mediums
SMS
The FortySixElksSMS have the following methods, all chainable.
Available Message methods for sms
from($mixed) Accepts a string containing A-Z, a-z, 0-9 up to 11 characters or numbers. Space is not supported. Sms will be sent with that name.
to($number) International phone number.
line($string) Every string in a line will be on its own row.
flash() Will set the message type to flash. Will not endup in sms inbox. See This tweet to find out how it looks on an iphone.
dry() Enable when you want to verify your API request without actually sending an SMS to a mobile phone.
No SMS message will be sent when this is enabled. To be able inspect a dry() request you need to
send your message to +4670000000 then you can inspect it at https://46elks.com/logs
whenDelivered('http://localhost.se/ping') This webhook URL will receive a POST request every time the delivery status changes.
dontLog() Enable to avoid storing the message text in your history.
The other parameters will still be stored.
MMS
To use MMS simply use new FortySixElksMMS() instead of new FortySixElksSMS()
The FortySixElksMMS have the following methods, all chainable.
Available Message methods
from($mixed). Accepts 'noreply' as a string or a MMS activated number
to($number). International phone number.
line($string). Every string in a line will be on its own row.
image(). URL to the image to send in mms.
Error handling
How to handle notification send errors
If for any reason there would be an error when sending a notification it will fire a
Illuminate\Notifications\Events\NotificationFailed event. You can then listen for that.
Example:
Event::listen(NotificationFailed::class, function($event){ info('Error while sending sms'); });
And the event has $event->notifiable, $event->notification, $event->channel and $event->data(where you have the exception at $event->data['exception'])
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email emil@dalnix.se instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
laravel-notification-channels/46elks 适用场景与选型建议
laravel-notification-channels/46elks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 113.13k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 laravel-notification-channels/46elks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravel-notification-channels/46elks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 113.13k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-18