helliomessaging / helliomessaging-laravel-notification-channel
Helliomessaging 通知通道,适用于 Laravel 5.3+
Requires
- php: ^8.0|^8.1|^8.2|^8.3
- guzzlehttp/guzzle: ^7.2
- illuminate/notifications: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
Requires (Dev)
- larastan/larastan: ^2.0
- laravel/pint: ^0.2|^1.13
- orchestra/testbench: ^7.0|^8.0|^9.0
- phpunit/phpunit: ^9.5|^10.5
- dev-master
- v1.4
- v1.3
- v1.2
- v1.1
- v1.0
- dev-dependabot/github_actions/dependabot/fetch-metadata-2.1.0
- dev-dependabot/composer/phpunit/phpunit-tw-9.5tw-10.5tw-11.0
- dev-dependabot/github_actions/actions/checkout-4
- dev-dependabot/github_actions/stefanzweifel/git-auto-commit-action-5
- dev-laravel-v9-support-and-improvements
- dev-HellioMessaging-patch-1
This package is auto-updated.
Last update: 2024-08-29 23:04:50 UTC
README
此包使您能够轻松使用Hellio Messaging发送通知
内容
安装
要获取 Hellio Messaging 通知通道的最新版本,适用于 Laravel 5.5 及以上版本,只需使用 Composer 安装项目。
composer require helliomessaging/helliomessaging-laravel-notification-channel
如果您使用 Laravel 5.5+,则不需要以下步骤。如果不行,安装包后,您需要注册服务提供者。打开 config/app.php
并将以下内容添加到 providers
键中。
NotificationChannels\Hellio\HellioServiceProvider::class
设置 Hellio Messaging 服务
首先,您必须在 Hellio 上有一个账户。一旦您注册了账户,请登录您的账户,然后点击 Hellio Messaging 控制面板上的 个人资料 & API 集成 菜单。点击 API 密钥 & Webhooks 选项卡,复制您的 客户端 ID
和 应用程序密钥
在终端运行
php artisan vendor:publish --provider="NotificationChannels\Hellio\HellioServiceProvider"
这将在您的 config
目录中创建一个 hellio.php
文件。
将您的 API 密钥粘贴到 config/hellio.php
配置文件中。您可以将下面的示例配置复制过来以开始使用
<?php return [ 'config' => [ 'client_id' => env('HELLIO_CLIENT_ID'), 'app_secret' => env('HELLIO_APP_SECRET') ], ];
或者
将 HELLIO_CLIENT_ID
和 HELLIO_APP_SECRET
添加到您的 .env
文件中
用法
现在您可以在任何使用 Hellio Messaging 发送的通知的 via()
方法中使用该通道
<?php use Illuminate\Notifications\Notification; use NotificationChannels\Hellio\HellioChannel; use NotificationChannels\Hellio\HellioMessage; class WelcomeSMS extends Notification { public function via($notifiable) { return [HellioChannel::class]; } public function toHellioSMS($notifiable) { return (new HellioMessage) ->from("HellioSMS") ->to("233242813656") //Add the country code to the number you wish to send to without the need to add the + ->content("Welcome to Hellio Messaging, a new world of litmitless possibilities.") ->messageType(0); //0 = text, 1 = flash } }
为了使您的通知知道您要发送到哪个电话号码,请将 routeNotificationForHellioSMS
方法添加到您的可通知模型中,例如您的用户模型
public function routeNotificationForHellioSMS() { return $this->phone; // where phone is a column in your users table; }
可用的消息方法
from($from)
: 设置发送者的 idsenderID($id)
:from($from)
的别名to($to)
: 设置收件人的电话号码msisdn($msisdn)
:to($to)
的别名messageType($messageType)
:type($type)
的别名content($content)
: 设置消息内容message($message)
:content($content)
的别名
有关可用方法的更多信息,请参阅 Hellio Messaging 文档门户
测试
composer test
安全
如果您发现任何安全相关的问题,请通过电子邮件support@helliomessaging.com联系,而不是使用问题跟踪器。
贡献
有关详细信息,请参阅CONTRIBUTING
致谢
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅许可证文件