當前位置:名人名言大全網 - 短信平臺 - 用JAVA開發短信方面有哪些基本知識

用JAVA開發短信方面有哪些基本知識

public static int sendSMS(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("/sdk2/BatchSend2.aspx?CorpID="+CorpID+"&Pwd="+Pwd+"&Mobile="+Mobile+"&Content="+send_content+"&Cell=&SendTime="+send_time);

BufferedReader in = null; int inputLine = 0; try {

System.out.println("開始發送短信手機號碼為 :"+Mobile);

in = new BufferedReader(new InputStreamReader(url.openStream()));

inputLine = new Integer(in.readLine()).intValue();

} catch (Exception e) {

System.out.println("網絡異常,發送短信失敗!");

inputLine=-2;

}

System.out.println("結束發送短信返回值: "+inputLine); return inputLine;

}