laravel-notification-channels/sipgate
Composer 安装命令:
composer require laravel-notification-channels/sipgate
包简介
Laravel notifications driver for sipgate.de
README 文档
README
This package makes it easy to send notifications using sipgate with Laravel 5.5+, 6.x, 7.x, 8.x, 9.x.
Contents
Installation
Install the package via composer:
composer require laravel-notification-channels/sipgate
Setting up the sipgate service
Extend config/services.php to read your sipgate credentials from your .env:
return [ ... 'sipgate' => [ 'username' => env('SIPGATE_USERNAME'), 'password' => env('SIPGATE_PASSWORD'), 'smsId' => env('SIPGATE_SMSID'), 'enabled' => env('SIPGATE_NOTIFICATIONS_ENABLED', true), ], ];
Add your sipgate credentials to your .env:
SIPGATE_NOTIFICATIONS_ENABLED=true SIPGATE_USERNAME=mail@example.com SIPGATE_PASSWORD=1234567890 SIPGATE_SMSID=s0
Web SMS Extensions / SMS ID
A Web SMS extension consists of the letter 's' followed by a number (e.g. s0). The sipgate API uses the concept of Web SMS extensions to identify devices within your account that are enabled to send SMS. In this context the term 'device' does not necessarily refer to a hardware phone but rather a virtual connection.
You can find out what your extension is as follows:
- Log into your sipgate account
- Use the sidebar to navigate to the Connections (Anschlüsse) tab
- Click SMS (if this option is not displayed you might need to book the Web SMS feature from the Feature Store)
- The URL of the page should have the form
https://app.sipgate.com/{...}/connections/sms/{smsId}where{smsId}is your Web SMS extension.
Send SMS with custom sender number
By default 'sipgate' will be used as the sender. It is only possible to change the sender to a mobile phone number by verifying ownership of said number. In order to accomplish this, proceed as follows:
- Log into your sipgate account
- Use the sidebar to navigate to the Connections (Anschlüsse) tab
- Click SMS (if this option is not displayed you might need to book the Web SMS feature from the Feature Store)
- Click the gear icon on the right side of the Caller ID box and enter the desired sender number.
- Proceed to follow the instructions on the website to verify the number.
Usage
Create a Notification
When your credentials are configured, you can use the sipgate channel in your notifications.
class ExampleNotification extends Notification { public function via($notifiable) { return ['sipgate']; } public function toSipgate($notifiable) { return SipgateMessage::create('Your message goes here…'); } }
Add a recipient
You can either choose to add the recipients number to the message itself:
public function toSipgate($notifiable) { return SipgateMessage::create('Your message goes here…')->recipient('00491234567890'); }
Or add a routeNotificationForSipgate method to your notifiable class:
class User extends Authenticatable { use Notifiable; public function routeNotificationForSipgate($notification) { return $this->phone_number; } }
If you define both, the message will be send to the number you defined in the message.
Sending On-Demand Notifications
If you want to send a notification to someone who is not registered in your application, use on-demand notifications:
Notification::route('sipgate', '00491234567890') ->notify(new ExampleNotification($message));
Available Message methods
public function toSipgate($notifiable) { return (new SipgateMessage('Your message goes here…')) ->message('…or here') ->recipient('00491234567890') ->sendAt(time() + 60) ->smsId('s0'); }
Optional: In order to send a delayed message set the desired date and time in the future (up to one month):
$message->sendAt(time() + 60);Note: The
sendAtmethod accepts a Unix timestamp.
Common Issues
SMS sent successfully but no message received
Possible reasons are:
- incorrect or mistyped phone number
- recipient phone is not connected to network
- long message text - delivery can take a little longer
HTTP Errors
| reason | errorcode |
|---|---|
| bad request (e.g. request body fields are empty or only contain spaces, timestamp is invalid etc.) | 400 |
| username and/or password are wrong | 401 |
| insufficient account balance | 402 |
| no permission to use specified SMS extension (e.g. SMS feature not booked, user password must be reset in web app) | 403 |
internal server error or unhandled bad request (e.g. smsId not set) |
500 |
Resources
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email mail@simonkubiak.de 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.
laravel-notification-channels/sipgate 适用场景与选型建议
laravel-notification-channels/sipgate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.33k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「notifications」 「laravel」 「sipgate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 laravel-notification-channels/sipgate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravel-notification-channels/sipgate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 laravel-notification-channels/sipgate 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova package that adds a notification feed in your Nova app.
PHP library for integrating with sipgate
A library for phone verification via Laravel notification channels. Any notification channel can be used as a sender, and Redis or MongoDB can be used as a storage.
Captures outgoing SMS notifications
Symfony Sipgate Notifier Bridge
Alfabank REST API integration
统计信息
- 总下载量: 1.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-23