$appId, 'accessKeySecret' => $appKey ]); $config->endpoint = 'dysmsapi.aliyuncs.com'; return new Dysmsapi($config); } /** 阿里云发送短信 * phone_numbers 手机号码 * 目前短信验证码模板变量为 code * 其他参数根据消息模板传递 * @param $data * @param $type * @return array */ public static function sendSms($data,$type = 1) { $template = env('alisms.template_sms_code'); if($type == 2) { $template = env('alisms.template_issue_code'); } else if ($type == 3) { $template = env('alisms.template_agreement_pay_code'); } $client = self::getInstance(env('alisms.app_id'),env('alisms.app_key')); $sms = new SendSmsRequest([]); $sms->phoneNumbers = $data['phone_numbers']; $sms->templateCode = $template; $sms->signName = env('alisms.sign_name'); $sms->templateParam = json_encode($data); $runtime = new RuntimeOptions([]); $result = $client->sendSmsWithOptions($sms,$runtime); return ['code' => $result->statusCode,'message' => $result->body->message]; } }