安装:composer require alibabacloud/dysmsapi-20170525 2.0.24
官方文档:短信服务_SDK中心-阿里云OpenAPI开发者门户 (aliyun.com)
特别注意:传入参数获得值形式
正确:
$PhoneNumbers = $postData['PhoneNumbers'];$signName = $postData['signName'];try {$sendSmsRequest = new SendSmsRequest(["phoneNumbers" => $PhoneNumbers,"signName" => $signName,"templateCode" => 'SMS_xxx',"templateParam" => json_encode(array('code' => $code))]);$runtime = new RuntimeOptions([]);
错误:
try {$sendSmsRequest = new SendSmsRequest(["phoneNumbers" => $postData['phoneNumbers'],"signName" => $postData['signName'],"templateCode" => 'SMS_xxxx',"templateParam" => json_encode(array('code' => $code))]);$runtime = new RuntimeOptions([]);
这样也不行
$sendSmsRequest = new SendSmsRequest($addData);
参考:php利用阿里云短信SDK实现短信发送功能_php 阿里云短信-CSDN博客