package com.tianjian.property.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class Sms {
// http://web.mobset.com/SDK/Sms_Send.asp?CorpID=124128&LoginName=wyyz&passwd=940043&send_no=13537626210&Timer=&msg=msgtest
//首易企业短信(不要名字)
public static final String CORP_ID = "124128liang";
public static final String LOGINNAME = "wyyzxiao";
public static final String PASSWORD = "940043lei";
private static Log log = LogFactory.getLog(Sms.class);
public static void main(String[] avgs) throws Exception {
String txt = SMSsend("18218712552", "你好测试 一下");
System.out.print(txt);
}
static public String SMSsend(String mobile, String content) throws Exception {
String url = "";
url = "http://web.mobset.com/SDK/Sms_Send.asp?CorpID=" + CORP_ID + "&LoginName=" + LOGINNAME + "&passwd="
+ PASSWORD + "&send_no=" + mobile + "&Timer=&msg=" + URLEncoder.encode(content, "GB2312");
log.warn("短信发送 mobileNo:" + mobile + " msg: " + content);
String result = "";
try {
URL U = new URL(url);
URLConnection connection = U.openConnection();
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
in.close();
} catch (Exception e) {
throw e;
}
if (result.indexOf("1") != 0) {
log.error("系统异常,短信发送失败 " +
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class Sms {
// http://web.mobset.com/SDK/Sms_Send.asp?CorpID=124128&LoginName=wyyz&passwd=940043&send_no=13537626210&Timer=&msg=msgtest
//首易企业短信(不要名字)
public static final String CORP_ID = "124128liang";
public static final String LOGINNAME = "wyyzxiao";
public static final String PASSWORD = "940043lei";
private static Log log = LogFactory.getLog(Sms.class);
public static void main(String[] avgs) throws Exception {
String txt = SMSsend("18218712552", "你好测试 一下");
System.out.print(txt);
}
static public String SMSsend(String mobile, String content) throws Exception {
String url = "";
url = "http://web.mobset.com/SDK/Sms_Send.asp?CorpID=" + CORP_ID + "&LoginName=" + LOGINNAME + "&passwd="
+ PASSWORD + "&send_no=" + mobile + "&Timer=&msg=" + URLEncoder.encode(content, "GB2312");
log.warn("短信发送 mobileNo:" + mobile + " msg: " + content);
String result = "";
try {
URL U = new URL(url);
URLConnection connection = U.openConnection();
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
in.close();
} catch (Exception e) {
throw e;
}
if (result.indexOf("1") != 0) {
log.error("系统异常,短信发送失败 " +