import java.net.URLEncoder; import java.net.URL; import java.net.URLConnection; import java.util.*; import java.io.*; class http_post { public String send_sms(String user_id, String password, String mobile_phone, String msg, String send_date, String subcode) { String ret_str = ""; try { // Construct data String data = "user_id=" + user_id + "&password=" + password + "&mobile_phone=" + mobile_phone + "&msg=" + URLEncoder.encode(msg, "GBK") + "&send_date=" + send_date + "&subcode=" + subcode; // Send data URL url = new URL("http://bms.hichina.com/sms_gateway/sms_api"); URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); // Get the response BufferedReader rd = new BufferedReader(new InputStreamReader(conn. getInputStream())); String line; while ( (line = rd.readLine()) != null) { ret_str += line; } wr.close(); rd.close(); } catch (Exception e) { System.out.println(e.toString()); } return ret_str; } public static void main(String[] args) throws IOException { http_post http= new http_post(); String ret=http.send_sms("4003","xxxxxxx","13900000000","fromjava中国万岁","","4003"); System.out.println(ret); } } 用户名,即企业代码: $user_id 密码:$password 接收短信的手机号(如果是多个手机号,用逗号分开,最多100个):$mobile_phone 要发送的短信内容:$msg 定时发送时间(格式为:年月日时分秒“040524165823”,如果即时发送置为空):$send_date 子特服号(与企业代码相同):$subCode
jms
最新推荐文章于 2024-01-06 16:18:47 发布