laravel-notification-channels / sipgate
为 sipgate.de 设计的 Laravel 通知驱动程序
Requires
- php: >=7.2
- ext-json: *
- guzzlehttp/guzzle: ^7.2
- illuminate/notifications: ~5.5 || ~6.0 || ~7.0 || ~8.0 || ~9.0
- illuminate/support: ~5.5 || ~6.0 || ~7.0 || ~8.0 || ~9.0
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-08-29 05:08:39 UTC
README
此包使得使用 sipgate.de 在 Laravel 5.5+、6.x、7.x、8.x、9.x 中发送通知变得简单。
内容
安装
通过 composer 安装此包
composer require laravel-notification-channels/sipgate
设置 sipgate 服务
扩展 config/services.php
以从您的 .env
中读取 sipgate 凭据
return [ ... 'sipgate' => [ 'username' => env('SIPGATE_USERNAME'), 'password' => env('SIPGATE_PASSWORD'), 'smsId' => env('SIPGATE_SMSID'), 'enabled' => env('SIPGATE_NOTIFICATIONS_ENABLED', true), ], ];
将您的 sipgate 凭据添加到您的 .env
SIPGATE_NOTIFICATIONS_ENABLED=true SIPGATE_USERNAME=mail@example.com SIPGATE_PASSWORD=1234567890 SIPGATE_SMSID=s0
Web SMS 扩展 / SMS ID
Web SMS 扩展由字母 's' 后跟一个数字组成(例如 s0
)。sipgate API 使用 Web SMS 扩展的概念来识别您账户中启用了发送短信的设备。在此上下文中,术语 '设备' 并不一定指硬件电话,而是虚拟连接。
您可以按照以下方式找到您的扩展
- 登录您的 sipgate 账户
- 使用侧边栏导航到 连接 (Anschlüsse) 选项卡
- 点击 短信(如果此选项未显示,您可能需要从功能商店预订 Web SMS 功能)
- 页面 URL 应该是以下形式
https://app.sipgate.com/{...}/connections/sms/{smsId}
,其中{smsId}
是您的 Web SMS 扩展。
使用自定义发送者号码发送短信
默认情况下,'sipgate' 将用作发送者。只有通过验证该号码的所有权才能将发送者更改为手机号码。为了完成此操作,请按照以下步骤操作
- 登录您的 sipgate 账户
- 使用侧边栏导航到 连接 (Anschlüsse) 选项卡
- 点击 短信(如果此选项未显示,您可能需要从功能商店预订 Web SMS 功能)
- 点击 主叫号码 方框右侧的齿轮图标并输入所需的发送者号码。
- 按照网站上的说明进行操作以验证该号码。
用法
创建通知
当您的凭据配置完成后,您可以在通知中使用 sipgate
通道。
class ExampleNotification extends Notification { public function via($notifiable) { return ['sipgate']; } public function toSipgate($notifiable) { return SipgateMessage::create('Your message goes here…'); } }
添加接收者
您可以选择将接收者号码添加到消息本身
public function toSipgate($notifiable) { return SipgateMessage::create('Your message goes here…')->recipient('00491234567890'); }
或将 routeNotificationForSipgate
方法添加到您的可通知类中
class User extends Authenticatable { use Notifiable; public function routeNotificationForSipgate($notification) { return $this->phone_number; } }
如果您定义了两个,则消息将发送到您在消息中定义的号码。
发送即时通知
如果您想向未在您的应用程序中注册的人发送通知,请使用即时通知
Notification::route('sipgate', '00491234567890') ->notify(new ExampleNotification($message));
可用的消息方法
public function toSipgate($notifiable) { return (new SipgateMessage('Your message goes here…')) ->message('…or here') ->recipient('00491234567890') ->sendAt(time() + 60) ->smsId('s0'); }
可选:为了发送延迟消息,请设置未来的日期和时间(最多一个月)
$message->sendAt(time() + 60);注意:
sendAt
方法接受一个 Unix 时间戳。
常见问题
短信发送成功但未收到消息
可能的原因包括
- 电话号码不正确或输入错误
- 接收者电话未连接到网络
- 长消息文本 - 交付可能需要更长的时间
HTTP 错误
资源
变更日志
请参阅变更日志以获取更多关于最近更改的信息。
测试
$ composer test
安全
如果您发现任何安全问题,请通过电子邮件mail@simonkubiak.de联系,而不是使用问题跟踪器。
贡献
请参阅贡献指南以获取详细信息。
致谢
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。