thinkstudeo/textlocal-notification-channel
Composer 安装命令:
composer require thinkstudeo/textlocal-notification-channel
包简介
Laravel notification channel for Textlocal Api
README 文档
README
This package makes it easy to send notifications using Textlocal with Laravel 5.6+
Supports using both Transactional and Promotional accounts with Textlocal at the same time.
Contents
Installation
composer require thinkstudeo/textlocal-notification-channel
Taking advantage of automatic package discovery available since Laravel 5.5, the service provider will be registered automatically.
Setting up the Textlocal service
Add your textlocal accounts, api url and credentials in the config/services.php file.
The url is required to be set in the config file because, textlocal has different urls for different countries.
Atleast for India, its different. https://api/textlocal.in/send/
... 'textlocal' => [ 'url' => 'https://api.textlocal.com/send/' //or 'https://api.textlocal.in/send/ - for India //Textlocal Transactional Account 'transactional' => [ 'apiKey' => env('TEXTLOCAL_TRANSACTIONAL_KEY'), 'from' => env('TEXTLOCAL_TRANSACTIONAL_FROM', 'TXTLCL') ], //Textlocal Promotional Account 'promotional' => [ 'apiKey' => env('TEXTLOCAL_PROMOTIONAL_KEY'), 'from' => env('TEXTLOCAL_PROMOTIONAL_FROM', 'TXTLCL') ] ], ...
Don't forget to add the keys to your .env file
...
TEXTLOCAL_TRANSACTIONAL_KEY= <Your Textlocal Transactional Account API KEY>
TEXTLOCAL_TRANSACTIONAL_FROM= <Registered/Approved sender for your Textlocal Transactional Account>
TEXTLOCAL_PROMOTIONAL_KEY= <Your Textlocal Promotional Account API KEY>
TEXTLOCAL_PROMOTIONAL_FROM= <Registered/Approved sender for your Textlocal Promotional Account>
...
Usage
To use the channel, include the NotificationChannels\Textlocal\TextlocalChannel class in the via() method of your notification class.
Using Textlocal Promotional Account
use Illuminate\Notifications\Notification; use NotificationChannels\Textlocal\TextlocalChannel; use NotificationChannels\Textlocal\TextlocalMessage; class SendBlackFridaySaleAnnouncement extends Notification { /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [TextlocalChannel::class]; } /** * Get the Textlocal / SMS representation of the notification. * * @param mixed $notifiable * @return NexmoMessage */ public function toTextlocal($notifiable) { return (new TextlocalMessage()) //Required // To send sms via your Textlocal promotional account //or transactional() to sent via Textlocal transactional account ->promotional() //Optional //If you don't provide a from, it will pick up the value from the config ->from('TXTLCL') //Optional //If you want to send a copy of the sms to another number eg an Admin ->cc('914545454545') //Required ->content('We are running a BlackFriday sale from tomorrow for 3 days with 40% off. Hurry !!! Grab the opportunity!'); } }
Using Textlocal Transactional Account
use Illuminate\Notifications\Notification; use NotificationChannels\Textlocal\TextlocalChannel; use NotificationChannels\Textlocal\TextlocalMessage; class SendLoginOtp extends Notification { /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [TextlocalChannel::class]; } /** * Get the Textlocal / SMS representation of the notification. * * @param mixed $notifiable * @return NexmoMessage */ public function toTextlocal($notifiable) { return (new TextlocalMessage()) //Required // To send sms via your Textlocal transactional account //or promotional() to sent via Textlocal promotional account ->transactional() //Optional //If you don't provide a from, it will pick up the value from the config ->from('TXTLCL') //Optional //If you want to send a copy of the sms to another number eg an Admin ->cc('914545454545') //Required //When sending through Textlocal transactional account, the content must conform to one of your approved templates. ->content('Your OTP for Application is 234567. It is valid for the next 10 minutes only.'); } }
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
Fill in the env values in the phpunit.xml.dist. The tests depends on these values.
<php> <env name="APP_ENV" value="Testing"/> <env name="TEXTLOCAL_TRANSACTIONAL_KEY" value="API_KEY for transactional account"/> <env name="TEXTLOCAL_TRANSACTIONAL_FROM" value="TXTLCL"/> <env name="TEXTLOCAL_PROMOTIONAL_KEY" value="API_KEY for transactional account"/> <env name="TEXTLOCAL_PROMOTIONAL_FROM" value="TXTLCL"/> <env name="TEST_TEXTLOCAL_TRANSACTIONAL_TEMPLATE" value="Your approved template for Textlocal transactional account"/> <env name="TEST_TEXTLOCAL_TRANSACTIONAL_MOBILE" value="Valid phone number"/> <env name="TEST_TEXTLOCAL_TRANSACTIONAL_CC" value="Another Valid Phone number"/> </php>
$ composer test
Security
If you discover any security related issues, please email neerav@thinkstudeo.com 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.
thinkstudeo/textlocal-notification-channel 适用场景与选型建议
thinkstudeo/textlocal-notification-channel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.87k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 thinkstudeo/textlocal-notification-channel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thinkstudeo/textlocal-notification-channel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-23