msonowal/laravel-notification-channel-textlocal 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

msonowal/laravel-notification-channel-textlocal

Composer 安装命令:

composer require msonowal/laravel-notification-channel-textlocal

包简介

Textlocal Notifications Channel for Laravel

README 文档

README

This package allows to send SMS using Textlocal API using laravel notifications channel textlocal sms

Supports Laravel 5.5 upto 10.x

Latest Stable Version License Total Downloads

This package makes it easy to send notifications using textlocal with Laravel 5.3.+

To use version ^2.3.0 onwards will require PHP 8.0

for other PHP version use upto ^2.2.0

Contents

Installation

Create an account in textlocal then create an API key or hash(password).

composer require msonowal/laravel-notification-channel-textlocal

Setting up the textlocal service

default config textlocal.php update where desired

Important Either specify a Key OR a Hash - don't enter both!

return [
	'username'  => env('TEXTLOCAL_USERNAME'),
	'password'  => env('TEXTLOCAL_PASSWORD'),
	'hash'      => env('TEXTLOCAL_HASH'),  //optional if api_key is set
	'api_key'   => env('TEXTLOCAL_API_KEY'), //optional if hash is set
	'sender'    => env('TEXTLOCAL_SENDER'),
	'request_urls' => [
		'IN' => 'https://api.textlocal.in/',
		'UK' => 'https://api.txtlocal.com/'
	],
	'country'   => env('TEXTLOCAL_COUNTRY', 'IN'),
    'extra' => [
        // extra config define keys as desired for use within the textlocal client config
        // if you want to use the custom client config for each notification or notifiable 
        // INotificationUsesTextlocalClientConfig
    ]public function getSenderId($notifiable)
### Configuring .env
TEXTLOCAL_USERNAME=Your email id or api key
TEXTLOCAL_HASH=get it from url '/docs/' under your API KEYS section
TEXTLOCAL_API_KEY get it from url '/docs/' under your API KEYS section
TEXTLOCAL_SENDER=Name of the Sender that will be displayed to the recipient (max 6 Characters).
TEXTLOCAL_COUNTRY=Your Two letter(ISO-3166-alpha-2) Country Code. It should be the Country of the TEXTLOCAL account. defaults to IN

### Publish Config
php artisan vendor:publish --tag=textlocal

Currently, only textlocal of two country is supported IN(India) and UK(United Kingdom). 

## Usage

Implement this method `routeNotificationForTextlocal()` in your notifiable class/model which will return array of mobile numbers. Please make sure the mobile number contains the dial code as well (e.g +91 for India). And lastly implement `toSms()` method in the notification class which will return the (string) sms or template that is defined in textlocal account that needs to be send.


## Usage

You can use the channel in your `via()` method inside the notification:

```php
use Illuminate\Notifications\Notification;
use NotificationChannels\Textlocal\TextlocalChannel;

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

    public function toSms($notifiable)
    {
        return 'Use 1234 as OTP for resetting your password.';
    }
}

In your notifiable model, make sure to include a routeNotificationForTextlocal() method, which returns a phone number or multiple numbers in array or an array of phone numbers.

public function routeNotificationForTextlocal(): array
{
    return [$this->mobile_no];
}

Annoynmous Notifable when say mobile no is not added to a notifiable model you can directly send to mobile no by using that

Notification::route('Textlocal', $mobileNo')->notify(new VerifyMobileNotification($otp));

Available Message methods

And if you want to have a specific sender based on Notification, e.g. like you are sending promotional notification using one and another for transaction then you can just define this method in your notification class which will return your sender id for that notification only

public function getSenderId($notifiable)
{
     return 'YOUR_SENDER_ID';
}

Unicode support If you want to send the notification content to have unicode support. Define this method in your notification which will return boolean based on which the sms will set the unicode mode in textlocal API

public function getUnicodeMode()
{
     return true;
}

A list of all available options

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email manash149@gmail.com instead of using the issue tracker.

Found any bugs or improvement open an issue or send me a PR

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

TODO

Need to convert to Guzzle Http as a Client in core Add more countries add tests

msonowal/laravel-notification-channel-textlocal 适用场景与选型建议

msonowal/laravel-notification-channel-textlocal 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31.53k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2017 年 11 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 msonowal/laravel-notification-channel-textlocal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 msonowal/laravel-notification-channel-textlocal 我们能提供哪些服务?
定制开发 / 二次开发

基于 msonowal/laravel-notification-channel-textlocal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 31.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 203
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-11-25