| | |
| | | package com.ruoyi.auth.utils; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.aliyuncs.DefaultAcsClient; |
| | | import com.aliyuncs.IAcsClient; |
| | | import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; |
| | | import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; |
| | | import com.aliyuncs.exceptions.ClientException; |
| | | import com.aliyuncs.profile.DefaultProfile; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | @Slf4j |
| | | public class SmsUtils { |
| | | public static String sendSms(String phoneNumber, String code) { |
| | | // 设置AccessKeyId、AccessKeySecret等信息 |
| | |
| | | try { |
| | | // 发送短信并打印结果 |
| | | SendSmsResponse response = client.getAcsResponse(request); |
| | | log.info("发送短信结果:{}", JSONObject.toJSONString(response)); |
| | | return response.getCode(); |
| | | } catch (ClientException e) { |
| | | e.printStackTrace(); |