PHP code example of hao / alidayu

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

    

hao / alidayu example snippets


$config = [
    'key_id' => '', // AccessKeyId
    'key_secret' => '',
    'sign_name' => '',//签名名称
    'code' => '',//模板CODE
];
$send = new \Aliyun\Send($config);

//发送短信
//短信参数内容
$data = [
    'code' => 12456,
    'product' => 'xxx'
];
$send->sendSms('手机号',$data);

$phone = [
    '手机号1',
    '手机号2'
];
//写法1(发送内容一致、短信签名一致):
//短信参数内容
$data = [
    'code' => 12456,
    'product' => 'xxx'
];
$send->sendBatchSms($phone,$data);
#################################################
//写法2(发送内容不一致、短信签名一致):
$data = [
    ['code' => 12456,'product' => 'xxx'],
    ['code' => 15555,'product' => 'xxx'],
];
$send->sendBatchSms($phone,$data);
##################################################
//写法3(发送内容不一致、短信签名不一致):
$data = [
    ['code' => 12456,'product' => 'xxx'],
    ['code' => 15555,'product' => 'xxx'],
];
$sign = ['签名1','签名2'];
$send->sendBatchSms($phone,$data,$sign);