PHP code example of hongyukeji / sms

1. Go to this page and download the library: Download hongyukeji/sms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hongyukeji / sms example snippets


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' => '短信发送成功!',
];

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

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

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

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

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

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

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

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