sykez/genusis-sms
Composer 安装命令:
composer require sykez/genusis-sms
包简介
Genusis Gensuite v10 API SMS Channel for Laravel.
README 文档
README
This package makes it easy to send notifications using Genusis SMS Gateway via Gensuite API with Laravel.
Contents
Installation
Install package via Composer:
composer require sykez/genusis-sms
Setting up the Genusis SMS service
Add the service configration into your config/services.php:
'genusis-sms' => [ 'client_id' => env('GENUSIS_SMS_CLIENT_ID', null), 'username' => env('GENUSIS_SMS_USERNAME', null), 'private_key' => env('GENUSIS_SMS_PRIVATE_KEY', null), 'url' => env('GENUSIS_SMS_URL', null), 'debug_log' => env('GENUSIS_SMS_DEBUG_LOG', false), ],
Add the environment variablesinto your .env and set your Client ID, Username, Private Key and API URL.
GENUSIS_SMS_CLIENT_ID=
GENUSIS_SMS_USERNAME=
GENUSIS_SMS_PRIVATE_KEY=
GENUSIS_SMS_URL=
Usage
Now you can send SMS from your notification:
Sending Notification
use Sykez\GenusisSms\GenusisSmsChannel; use Sykez\GenusisSms\GenusisSmsMessage; use Illuminate\Notifications\Notification; class SendSms extends Notification { public function via($notifiable) { return [GenusisSmsChannel::class]; } public function toSms($notifiable) { return (new GenusisSmsMessage)->content("Hello there!"); } }
Routing Notification
You can route the notification to a phone number with to():
public function toSms($notifiable) { return (new GenusisSmsMessage)->content("Hello there!")->to(01234567891); }
Or you can add routeNotificationForSms() method in your notifiable model:
public function routeNotificationForSms() { return $this->phone_number; }
You can also do on-demand notifications:
use Illuminate\Support\Facades\Notification; Notification::route('sms', '01234567891')->notify(new App\Notifications\SendSms(['Hello again.']));
Logs & Debug
You can set your GENUSIS_SMS_DEBUG_LOG=true in your .env to send all requests and responses to into your Laravel logs.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-20