SMS sent, never so simple.

v1.7.1 2019-10-13 10:42 UTC

This package is auto-updated.

Last update: 2024-12-11 21:34:22 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

全网首款支持所有短信服务商,自由扩展,无缝对接。

采用鸿宇科技专利《宏观设计模式》开发。

更多请点击 https://www.hongyuvip.com

项目迁移至 https://github.com/hongyukeji/php-sms

特点

  • 支持全网络短信服务商
  • 支持自由扩展且易维护

支持

环境

  • PHP >= 5.6.0

安装

$ composer require hongyukeji/sms

使用

PHP框架中使用,配置文件参考 'docs/config/config.php'

短信发送参数详解: send([参数1-手机号: 支持字符串和数组格式],[参数2-模板: 支持模板Code和模板内容],[参数3-模板参数: 模板对应的参数, 数组格式],[参数4-短信服务商: 设置短信发送服务商, 该参数为空时调用配置文件中默认短信服务商])

use HongYuKeJi\Helpers\Sms;

$config = [
    'default' => [
        'gateway' => 'aliyun',
    ],
    'gateways' => [
        'yunpian' => [
            'apikey' => '',
        ],
        'aliyun' => [
            'accessKeyId' => '',
            'accessKeySecret' => '',
            'signName' => '',
        ],
        'qcloud' => [
            'appid' => '',
            'appkey' => '',
            'smsSign' => '',
        ],
        'duanxinbao' => [
            'user' => '',
            'pass' => '',
            'signName' => '',
        ],
        'submail' => [
            'appid' => '',
            'appkey' => '',
        ],
        'sendcloud' => [
            'sms_user' => '',
            'sms_key' => '',
        ],
        'ihuyi' => [
            'apiid' => '',
            'apikey' => '',
        ],
    ],
];

$sms = new Sms($config);

// templateCode + templateParam
$resultTemplateCode = $sms->send('13800138000', 'SMS_88888888', [
    'code' => '1234',
    'time' => '15分钟',
]);

var_dump($resultTemplateCode);

// templateContent + templateParam
$resultTemplateContent = $sms->send(['13800138000', '13900139000'], '您的验证码是%s。有效期为%s,请尽快验证!', [
    'code' => '1234',
    'time' => '15分钟',
], 'duanxinbao');

var_dump($resultTemplateContent);

// return 返回值 status: success => 发送成功, fail => 发送失败
$result = [
    'status' => 'success',
    'message' => '短信发送成功!',
];

维护

配置

使用说明:templateCode + templateParam

'aliyun' => [
    'accessKeyId' => '',
    'accessKeySecret' => '',
    'signName' => '',
],

使用说明:templateCode + templateParam

'yunpian' => [
    'apikey' => '',
],

使用说明:templateCode + templateParam

'qcloud' => [
    'appid' => '',
    'appkey' => '',
    'smsSign' => '',
],

使用说明:templateContent + templateParam

'duanxinbao' => [
    'user' => '',
    'pass' => '',
    'signName' => '',
],

使用说明:templateCode + templateParam

'submail' => [
    'appid' => '',
    'appkey' => '',
],

使用说明:templateCode + templateParam

'sendcloud' => [
    'sms_user' => '',
    'sms_key' => '',
],

使用说明:templateContent + templateParam

'ihuyi' => [
    'apiid' => '',
    'apikey' => '',
],

使用说明:templateContent + templateParam

'chuanglan' => [
    'api_send_url' => '',
    'api_variable_url' => '',
    'api_balance_query_url' => '',
    'api_account' => '',
    'api_password' => '',
    'sms_sign' => '',
],