一、POM文件
<!-- https://mvnrepository.com/artifact/com.aliyun/tea-console -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-console</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-openapi</artifactId>
<version>0.2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-util</artifactId>
<version>0.2.20</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>2.0.24</version>
<scope>compile</scope>
</dependency>
二、java测试用例
// This file is auto-generated, don't edit it. Thanks.
package com.sino.event.server;
public class SampleTest {
/**
* 使用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_);
// 请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID 和 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html
com.aliyun.dysmsapi20170525.Client client = SampleTest.createClient("LTAI5tAnr8yfrd*********", "GV9rj5QTza9mmTExtwFUsL*******");
com.aliyun.dysmsapi20170525.models.QuerySendDetailsRequest querySendDetailsRequest = new com.aliyun.dysmsapi20170525.models.QuerySendDetailsRequest()
.setPhoneNumber("1829410****1")
.setSendDate("20230802")
.setPageSize(10L)
.setCurrentPage(1L);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
com.aliyun.dysmsapi20170525.models.QuerySendDetailsResponse resp = client.querySendDetailsWithOptions(querySendDetailsRequest, runtime);
com.aliyun.teaconsole.Client.log(com.aliyun.teautil.Common.toJSONString(resp));
}
}
阿里文档:如何查询短信发送详情_短信服务-阿里云帮助中心 (aliyun.com)