aungmyokyaw / tmh
Tah Moe Hnye`的Laravel SMS包
v1.0.4
2023-04-02 21:54 UTC
Requires
- php: ^7.2|^8.0|^8.1|^8.2
- guzzlehttp/guzzle: ^6.3|^7.5
- laravel/framework: ^10.0|^9.0|^8.0|^7.0
Requires (Dev)
- orchestra/testbench: ^v7.0.0
- phpunit/phpunit: ^9.6
README
关于
本包专门为Tah Moe Hnye` SMS设计,提供了一个简单高效的方式使用Laravel发送短信。具有易于集成、可定制的OTP和详细消息等特性。
安装
composer require aungmyokyaw/tmh
配置
您需要将配置文件发布到您的应用程序中。您可以使用以下命令完成此操作
php artisan vendor:publish --tag="tmh-config"
发布包的配置文件后,您将在config/tmh.php
中找到该文件。您需要填写此文件中的必要数据才能使用该包。
使用示例
要使用该包在您的应用程序中,您需要导入TMH类
use TMH;
SMS
然后您可以在TMH类上调用SMS
方法来处理TMH数据。例如
$response = TMH::sms('This is test SMS.')->send('959xxxxxxxxx');
一次性密码(OTP)
然后您可以调用OTP
方法。例如
$response = TMH::otp()->send('959xxxxxxxxx');
这将向电话号码959xxxxxxxxx发送OTP。请确保用您要发送OTP的实际电话号码替换此电话号码。默认OTP的type
为数字,length
为6。
如果您想要自定义OTP,可以修改以下代码
$response = TMH::otp('alphabet',8)->send('959xxxxxxxxx');
dd($response);
这意味着OTP将由随机的字母数字字符组成,长度为8个字符。
OTP参数
TMH::otp($type, $length)->send('959xxxxxxxxx');
otp()
方法接受两个可选参数
$type
:要发送的OTP类型,例如numeric
、alphabet
或alphanumeric
。如果未指定,则默认为numeric
。$length
:要发送的OTP长度,例如4或6。如果未指定,则默认为6
。
自定义OTP短信消息
默认OTP消息为您的OTP是:otp
。如果您想更改自定义消息,您需要发布translation
文件。
php artisan vendor:publish --tag="tmh-translation"
发布包的翻译文件后,您可以在resources/lang/vendor/tmh
中找到该文件。