curder / laravel-aliyun-sms by curder

阿里云短信服务 - Laravel
3,524
11
3
Package Data
Maintainer Username: curder
Maintainer Contact: curder@foxmail.com (curder)
Package Create Date: 2017-07-03
Package Last Update: 2017-07-03
Language: PHP
License: MIT
Last Refreshed: 2024-11-15 15:06:09
Package Statistics
Total Downloads: 3,524
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 11
Total Watchers: 3
Total Forks: 4
Total Open Issues: 0

laravel-aliyun-sms

阿里云短信服务-Laravel,基于api V20170525版本。

阿里云短信服务地址接入流程:https://help.aliyun.com/document_detail/55288.html?spm=5176.sms-account.109.10.56907c16jbje4H

Install

composer require curder/laravel-aliyun-sms

Config

在Laravel项目的.env文件中配置如下信息。

ALIYUN_SMS_ENABLE_HTTP_PROXY=false
ALIYUN_SMS_HTTP_PROXY_IP=127.0.0.1
ALIYUN_SMS_HTTP_PROXY_PORT=8888
ALIYUN_SMS_REGION_ID=cn-hangzhou
ALIYUN_SMS_AK=""
ALIYUN_SMS_AS=""
ALIYUN_SMS_SIGN_NAME=""

注册ServiceProvide

在项目的config/app.php文件中providers数组中新增如下行:

Curder\LaravelAliyunSms\ServiceProvider::class,

生成配置文件

php artisan vendor:publish --provider="Curder\LaravelAliyunSms\ServiceProvider"

生成的文件在config/aliyunsms.php,可以前往修改。

How to use ?

$smsService = App::make(Curder\LaravelAliyunSms\AliyunSms::class);
$smsService->send(strval($mobile), $tplId , $params);

接受的参数分别是:

  • string $mobile -> 短信接受手机号
  • string $tplId -> 模板签名id,需要在阿里云后台申请,并通过审核才可以使用
  • array $params -> 发送参数