SMS API Documentation: http://www.lx598.com/apitext.html
/** * used to format the seed parameter */ private static final String dateFormatStr="yyyyMMddHHmmss"; public static void main(String[] args) { // output send result System.out.println(LxSdkImpl.sendSms("accName", "accPwd", "mobies", "content","")); // output query report results System.out.println(LxSdkImpl.qryReport("accName", "accPwd")); //output query balance result System.out.println(LxSdkImpl.qryBalance("accName", "accPwd")); //Output the result of querying the uplink SMS System.out.println(LxSdkImpl.receiveSms("accName", "accPwd")); } /** * send messages * @param accName username * @param accPwd password * @param seed Current time format: YYYYMMDD HHMISS Example: 20130806102030 * @param aimcodes mobile phone numbers are separated by commas * @param content add a signature after the content * @param schTime Timing time format such as: 2010-01-01 08:00:00 * @return The result returned by the server is ok: business id or error code */ public static String sendSms(String accName,String accPwd,String mobies,String content,String schTime){ StringBuffer sb = new StringBuffer("http://sdk.lx198.com/sdk/send2?"); try { String seed=new SimpleDateFormat(dateFormatStr).format(new Date()); sb.append("&accName="+accName); sb.append("&seed="+seed); sb.append("&accPwd="+MD5.getMd5String(MD5.getMd5String(accPwd)+seed)); sb.append("&aimcodes="+mobies); sb.append("&schTime="+URLEncoder.encode(schTime,"UTF-8")); //Encode conversion of spaces and punctuations sb.append("&content="+URLEncoder.encode(content,"UTF-8")); //Encode conversion in Chinese URL url = new URL(sb.toString()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); return in.readLine(); } catch (Exception e) { e.printStackTrace (); } return null; } /** * Check balances * @param accName username * @param accPwd original password * @param seed Current time format: YYYYMMDD HHMISS Example: 20130806102030 * @return The result returned by the server is ok: business id or error code */ public static String qryBalance(String accName,String accPwd){ StringBuffer sb = new StringBuffer("http://sdk.lx198.com/sdk/qryBalance2?"); try { String seed=new SimpleDateFormat(dateFormatStr).format(new Date()); sb.append("&accName="+accName); sb.append("&seed="+seed); sb.append("&accPwd="+MD5.getMd5String(MD5.getMd5String(accPwd)+seed)); URL url = new URL(sb.toString()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); return in.readLine(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace (); } return null; } /** * Query receipt report * @param accName username * @param accPwd original password * @param seed Current time format: YYYYMMDD HHMISS Example: 20130806102030 * The format of the query report returned by @return is: business id, mobile phone number, status; business id, mobile phone number, status Status 1 means success; 0 means failure */ public static String qryReport(String accName,String accPwd){ StringBuffer sb = new StringBuffer("http://sdk.lx198.com/sdk/qryReport2?"); try { String seed=new SimpleDateFormat(dateFormatStr).format(new Date()); sb.append("&accName="+accName); sb.append("&seed="+seed); sb.append("&accPwd="+MD5.getMd5String(MD5.getMd5String(accPwd)+seed)); URL url = new URL(sb.toString()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); return in.readLine(); } catch (Exception e) { e.printStackTrace (); } return null; } /** * Query uplink SMS * @param accName username * @param accPwd password * @param seed Current time format: YYYYMMDD HHMISS Example: 20130806102030 * @return The returned uplink SMS message format is: Signature $$Uplink Mobile Number$$Uplink Content$$Uplink Time####Signature$$Uplink Mobile Number$$Uplink Content$$Uplink Time */ public static String receiveSms(String accName,String accPwd){ StringBuffer sb = new StringBuffer("http://sdk.lx198.com/sdk/receiveSms2?"); try { String seed=new SimpleDateFormat(dateFormatStr).format(new Date()); sb.append("&accName="+accName); sb.append("&seed="+seed); sb.append("&accPwd="+MD5.getMd5String(MD5.getMd5String(accPwd)+seed)); URL url = new URL(sb.toString()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); return in.readLine(); } catch (Exception e) { e.printStackTrace (); } return null; }