- 添加maven依赖
<dependency>
<groupId>com.github.100sms</groupId>
<artifactId>yibai-sms-java-sdk</artifactId>
<version>1.0.2</version>
</dependency>
如果非maven项目可手动获取jar包
- 调用方法
private static final String serverUrl = "xxxxxxxxx";//修改为相应的api地址
private static final String apikey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";//修改为您的apikey
private static final YibaiClient client = new DefaultYibaiClient(serverUrl, apikey);
public void testSmsBatchSubmit() {
try {
client.smsBatchSubmit(Arrays.asList(
new SmsSubmit("187xxxxxxxx", "【亿佰云通讯】您的验证码是:1234"),//修改为你要发送的手机号和短信内容
new SmsSubmit("186xxxxxxxx", "【亿佰云通讯】您的验证码是:5678")//修改为你要发送的手机号和短信内容
));
} catch (YibaiApiException e) {
System.out.println("YibaiApiException, code: " + e.getCode() + ", message: " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
}
}
- 请使用jdk1.7或更高版本
- 测试sdk请使用YibaiClientTest类,http请求测试请使用JavaSmsApiSample类
- 详细api文档请参考https://www.100sms.cn/helpSupports