1.了解阿里云用户权限操作
需要通过个人账户获得 授权码(id、密码),再通过这些信息获得服务
阿里云网址 :https://www.aliyun.com/
com.alibaba fastjson 1.2.79 org.springframework.boot spring-boot-starter-data-redis com.aliyun dysmsapi20170525 2.0.23
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);// 访问的域名config.endpoint = "dysmsapi.aliyuncs.com";return new com.aliyun.dysmsapi20170525.Client(config);}public static void main(String[] args_) throws Exception {java.util.List args = java.util.Arrays.asList(args_);// 工程代码泄露可能会导致AccessKey泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.htmlcom.aliyun.dysmsapi20170525.Client client = Sample.createClient("accessKeyId", "accessKeySecret");com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest();com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();try {// 复制代码运行请自行打印 API 的返回值client.sendSmsWithOptions(sendSmsRequest, runtime);} catch (TeaException error) {// 如有需要,请打印 errorcom.aliyun.teautil.Common.assertAsString(error.message);} catch (Exception _error) {TeaException error = new TeaException(_error.getMessage(), _error);// 如有需要,请打印 errorcom.aliyun.teautil.Common.assertAsString(error.message);} }
}
上一篇:leectcode 回文数
下一篇:【Python】特征编码