📄 http_post.java
字号:
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)
{
http_post http= new http_post();
String ret=http.send_sms("4003","xxxxxxx","13649086985","fromjava中国万岁","","4003");
System.out.println(ret);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -