zjutsxj/alisms

阿里云短信发送扩展 thinkphp5.1

1.1.3 2020-05-30 14:54 UTC

This package is auto-updated.

Last update: 2024-09-29 05:29:48 UTC


README

在 Thinkphp5.1 中使用阿里云短信服务

参考:https://help.aliyun.com/document_detail/55359.html?spm=a2c4g.11186623.4.3.79a04e6atw9hnY
说明:[PHP](仅支持5.5以上版本),[SDK轻量版](轻量版支持php>=5.4,使用方法:先运行Test.php测试PHP环境,测试成功后再运行Demo)

参考:https://github.com/aliyun/openapi-sdk-php
本扩展仅封装了 [SDK轻量版] 的功能,也只能发送验证码短信。

安装

composer require zjutsxj/alisms

配置文件config/alisms.php

<?php
return [
    'security' => false, // 是否启用https
    'host' => 'dysmsapi.aliyuncs.com', // 服务器

    'access_key' => '',
    'access_secret' => '',

    'cn_sign_name' => '', // 国内 短信签名
    'cn_temp_code' => '', // 国内 短信模板Code

    'en_sign_name' => '', // 国际 短信签名
    'en_temp_code' => '', // 国际 短信模板Code
];

使用

use yimao\alisms\Sms;

$sms = new Sms;
// 发送验证码 短信模板中有${code}变量
$sms->sendCode('18759201xxx', '123456');
// 发送动态密码 短信模板中有${password}变量
$sms->sendPassword('18759201xxx', '123456');

配置说明