laravel-notification-channels/africastalking
Composer 安装命令:
composer require laravel-notification-channels/africastalking
包简介
This package makes it easy to send notifications via AfricasTalking with Laravel
README 文档
README
This package makes it easy to send notifications using AfricasTalking with Laravel.
Contents
- About
- Installation
- Setting up the AfricasTalking service
- Usage
- Testing
- Security
- Contributing
- Credits
- License
About
This package is part of the Laravel Notification Channels project. It provides additional Laravel Notification channels to the ones given by Laravel itself.
The AfricasTalking channel makes it possible to send out Laravel notifications as a SMS using AfricasTalking API.
Installation
You can install this package via composer:
composer require laravel-notification-channels/africastalking
The service provider gets loaded automatically.
Setting up the AfricasTalking service
You will need to Register and then go to your sandbox app Go To SandBox App. Click on settings Within this page, you will generate your Username and key. Place them inside your .env file. Remember to add your Sender ID that you will be using to send the messages.
Please note if you do not have a VALID sender_ID remove "AT_FROM" from your .env or leave it as ""
AT_USERNAME="" AT_KEY="" AT_FROM="" // please note if you do not have a valid sender_ID remove this or leave it as ""
To load them, add this to your config/services.php . This will load the AfricasTalking data from the .env file.file:
'africastalking' => [ 'username' => env('AT_USERNAME'), 'key' => env('AT_KEY'), 'from' => env('AT_FROM'), ]
Add the routeNotifcationForAfricasTalking method on your notifiable Model. If this is not added,
the phone_number field will be automatically used.
<?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * Route notifications for the Africas Talking channel. * * @param \Illuminate\Notifications\Notification $notification * @return string */ public function routeNotificationForAfricasTalking($notification) { return $this->phone_number; } }
Usage
To use this package, you need to create a notification class, like NewsWasPublished from the example below, in your Laravel application. Make sure to check out Laravel's documentation for this process.
<?php use NotificationChannels\AfricasTalking\AfricasTalkingChannel; use NotificationChannels\AfricasTalking\AfricasTalkingMessage; class NewsWasPublished extends Notification { /** * Get the notification's delivery channels. * * @param mixed $notifiable * @return array */ public function via($notifiable) { return [AfricasTalkingChannel::class]; } public function toAfricasTalking($notifiable) { return (new AfricasTalkingMessage()) ->content('Your SMS message content'); } }
You can also modify who the notification(SMS) is sent from, this will override the AT_FROM= in your .env Please only do this if you have a VALID sender_ID
return (new AfricasTalkingMessage()) ->content("Your SMS message content") ->from("set any sender id/name here");
You can also modify who the notification(SMS) is sent to (the recipient)
return (new AfricasTalkingMessage()) ->content("Your SMS message content") ->to("put the recipient phone number here"); //eg ->to(1111111111)
It's important to know the Order in which the recipient phone number the notification(SMS) will be sent to will be used
-
If you have defined the routeNotificationForAfricasTalking() method on the Notifiable class (User.php in this case) and returned a valid phone number, then that will be used.
-
if you did not define routeNotificationForAfricasTalking() method on the Notifiable class (User.php in this case), then the phone_number attribute of the User will be used ($user->phone_number)
-
Lastly if the recipient phone number is set using ->to(1111111), this will override the phone number provided in either 1 or 2.
return (new AfricasTalkingMessage()) ->content("Your SMS message content") ->to("put the recipient phone number here"); //eg ->to(11111111)
Testing
$ composer test
Security
If you discover any security-related issues, please email osaigbovoemmanuel1@gmail.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.
How do I say Thank you?
Please buy me a cup of coffee https://www.paypal.com/paypalme/osaigbovoemmanuel , Leave a star and follow me on Twitter .
laravel-notification-channels/africastalking 适用场景与选型建议
laravel-notification-channels/africastalking 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30.98k 次下载、GitHub Stars 达 25, 最近一次更新时间为 2020 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「notification」 「laravel」 「Africastalking」 「notification-channel」 「laravel-notification-channel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 laravel-notification-channels/africastalking 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravel-notification-channels/africastalking 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 laravel-notification-channels/africastalking 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Apple Push Notification & Feedback Provider
Throttle notifications on a per-channel basis
Extensible library for building notifications and sending them via different delivery channels.
Enterprise USSD framework for Laravel. Multi-provider support (Safaricom, Airtel, MTN), session management, menu builders, form collection, pagination, security, analytics, and i18n for African mobile networks.
Simple javascript toast notifications
Africastalking Laravel 5 Gateway
统计信息
- 总下载量: 30.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 25
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-17