乐趣区

关于短信:使用flcdysms实现阿里云短信发送

一:文档地址

github:https://github.com/flc1125/dysms
composer:https://packagist.org/packages/flc/dysms

二:实现短信发送

<?php
use Flc\Dysms\Client;
use Flc\Dysms\Request\SendSms;

$config = [
    'accessKeyId'    => 'LTAIbVA2LRQ1tULr',
    'accessKeySecret' => 'ocS48RUuyBPpQHsfoWokCuz8ZQbGxl',
];

$client  = new Client($config);
$sendSms = new SendSms;
$sendSms->setPhoneNumbers('发送手机号');
$sendSms->setSignName('短信签名');
$sendSms->setTemplateCode('短信模板 CODE');
$sendSms->setTemplateParam('短信模板变量对应的理论值。反对传入多个参数,例:["code"=>"123"]');
$sendSms->setOutId('内部流水扩大字段,无特殊要求疏忽此字段');

print_r($client->execute($sendSms));
退出移动版