还是第三方的小平台的demo简单,基本没有任何封装的东西,简单易懂好实现,基本就是填上账号就能用.
package com.test;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class SendMessage {
@SuppressWarnings({ "static-access", "static-access" })
public static void main(String[] args) {
try {
SendMessage sm = new SendMessage();
// Http Get请求
//test.sendSMSGet("13439117920",
//"Java Http GET 方式短信调试已经成功!!!!!【成都凌凯】", "");
String code=random.getThree();
// Http post 请求
sm.sendSMSPost("手机号",
"短信内容:"+code+ "有效时间为五分钟", "");
String CorpID = "";// 账户名
String Pwd = "";// 密码
//回复信息查询
// test.getReplyMsg(CorpID, Pwd);
//余额查询
sm.getSelSum(CorpID, Pwd);
//获取禁止号码
// test.getNotSend(CorpID, Pwd);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
/**
* http get请求 发送方法 其他方法同理 返回值>0 提交成功
*
* @param Mobile
* 手机号码
* @param Content
* 发送内容
* @param send_time
* 定时发送的时间;可以为空,为空时为及时发送
* @return 返回值
* @throws MalformedURLException
* @throws UnsupportedEncodingException
*/
public static int sendSMSGet(String Mobile, String Content, String send_time)
throws MalformedURLException, UnsupportedEncodingException {
URL url = null;
String CorpID = "";// 账户名
String Pwd = "";// 密码
String send_content = URLEncoder.encode(
Content.replaceAll("<br/>", " "), "GBK");// 发送内容
url = new URL("https://sdk2.028lk.com/sdk2/BatchSend2.aspx?CorpID="