PHP code example of fastgoo / aliyun-sms

1. Go to this page and download the library: Download fastgoo/aliyun-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/ */

    

fastgoo / aliyun-sms example snippets




use Aliyun\Sms\Api AS SmsApi;

/** 短信推送配置信息 **/
$config = [
    'accessKeyId' => '你的accessKeyId',
    'accessKeySecret' => '你的accessKeySecret',
    'signName' => '签名名称',
    'defaultTemplate' => '默认模板code',
];

$smsApi = new SmsApi($config);

//例如模板code的模板内容为:您的验证码为:${code},该验证码 5 分钟内有效,请勿泄漏于他人。
$templateCode = "模板code";

//模板参数 code为模板内容里面的变量
$param = ['code'=>'123456'];
$phone = '手机号码';
$result = $smsApi->setTemplate($param,$templateCode)->send($phone);