package com.xhpc.general.util.sms;

import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.teaopenapi.models.Config;

/**
 * @Author WH
 * @Date 2021/10/25 16:16
 * @Description 使用阿里云提供SDK进行短信发送
 * @Param
 * @Return
 * @Since version-1.0
 */
public class SmsUtil {

    private static String accessKeyId = "LTAI5tHxc8hrG6cT5nDtEkiV";
    private static String accessKeySecret = "5kFEaIFE7eeODxKQwD5mvTRF48MK6w";

    /**
     * 使用AK&SK初始化账号Client
     *
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {

        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "dysmsapi.aliyuncs.com";
        return new com.aliyun.dysmsapi20170525.Client(config);
    }

    public static void main(String[] args_) throws Exception {

        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.dysmsapi20170525.Client client = SmsUtil.createClient(accessKeyId, accessKeySecret);
        SendSmsRequest sendSmsRequest = new SendSmsRequest()
                .setPhoneNumbers("18123374652")
                .setSignName("翔桦充电订单异常")
                .setTemplateCode("SMS_462691150")
                .setTemplateParam("尊敬的管理员，用户退款订单：458765465461，有问题请速速查看。");
        // 复制代码运行请自行打印 API 的返回值
        client.sendSms(sendSmsRequest);







    }

}

