import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.tea.*;
import com.aliyun.teautil.models.RuntimeOptions;
public class Sample {
/**
* 使用 AK&SK 初始化账号 Client
* @param accessKeyId
* @param accessKeySecret
* @return Client
* @throws Exception
*/
public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String
accessKeySecret) throws Exception {
com.aliyun.teaopenapi.models.Config config = new
com.aliyun.teaopenapi.models.Config()
// 必填,您的 AccessKey ID
.setAccessKeyId(accessKeyId)
// 必填,您的 AccessKey Secret
.setAccessKeySecret(accessKeySecret);
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
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 =
Sample.createClient(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"),
System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new
com.aliyun.dysmsapi20170525.models.SendSmsRequest()
.setPhoneNumbers("18333162697")
.setTemplateCode("SMS_463679948")
.setTemplateParam("{\"code\":\"12 哈哈哈 34\"}")
.setSignName("阿萨德看看");
try {
// 复制代码运行请自行打印 API 的返回值
SendSmsResponse sendSmsResponse =
client.sendSmsWithOptions(sendSmsRequest, new RuntimeOptions());
System.out.println(sendSmsResponse);
} catch (TeaException error) {