xutl / laravel-sms
This is a SMS.
1.0.2
2018-12-18 09:06 UTC
Requires
- overtrue/easy-sms: ^1.1
This package is auto-updated.
Last update: 2024-12-18 22:31:39 UTC
README
This is a sms expansion for the laravel
平台支持
- 阿里云
- 云片
- Submail
- 螺丝帽
- 容联云通讯
- 互亿无线
- 聚合数据
- SendCloud
- 百度云
- 华信短信平台
- 253云通讯(创蓝)
- 融云
- 天毅无线
- 腾讯云 SMS
- 阿里大于(不推荐使用,请使用阿里云)
- 阿凡达数据
环境需求
- PHP >= 5.6
Installation
composer require xutl/laravel-sms
for Laravel
This service provider must be registered.
// config/app.php 'providers' => [ '...', XuTL\Sms\SmsServiceProvider::class, ];
add the config file: config/sms.php
add config
use Overtrue\EasySms\Strategies\OrderStrategy; return [ // HTTP 请求的超时时间(秒) 'timeout' => 5.0, /* |-------------------------------------------------------------------------- | Default Setting |-------------------------------------------------------------------------- | | This option defines the default sms gateway that gets used when writing | messages to the sms. The name specified in this option should match | one of the gateways defined in the "gateways" configuration array. | */ 'default' => [ // 网关调用策略,默认:顺序调用 'strategy' => OrderStrategy::class, /* |-------------------------------------------------------------------------- | Default Gateways |-------------------------------------------------------------------------- | | This option defines the default sms gateway that gets used when writing | messages to the sms. The name specified in this option should match | one of the gateways defined in the "gateways" configuration array. | */ 'gateways' => [ ], ], /* |-------------------------------------------------------------------------- | Log Gateways |-------------------------------------------------------------------------- | | Here you may configure the sms gateways for your application. This gives | you a variety of powerful log handlers / formatters to utilize. | | Available Drivers: "aliyun", "alidayu", "yunpian", "submail", | "errorlog", "luosimao", "yuntongxun", "huyi" | "juhe", "sendcloud", "baidu", "huaxin", "chuanglan" | "rongcloud", "tianyiwuxian", "twilio", "qcloud", "avatardata" | */ 'gateways' => [ //Doc // https://github.com/overtrue/easy-sms ], ];
Use
try { $res = sms('13800138000', ['content' => '您的验证码为: 6379','template' => '259734', 'data' => [6379]]); print_r($res); } catch (InvalidArgumentException $e) { print_r($e->getMessage()); } catch (NoGatewayAvailableException $e) { print_r($e->getMessage()); }