使用HttpURLConnection发送短信
来源:互联网 发布:数据结构排序算法心得 编辑:程序博客网 时间:2024/05/16 04:55
public int sendMobile(String receiveMobile, String content) {
/**设置短信参数**/String msg_ip = "";
String msg_user_id = "";
String msg_company_id = "";
String msg_pwd = "";
String msg_key = "";
msg_ip = Config.MSG_IP;
msg_user_id = Config.MSG_USER_ID;
msg_company_id = Config.MSG_COMPANY_ID;
msg_pwd = Config.MSG_PWD;
msg_key = Config.MSG_KEY;
/**发动短信动作**/
try {
content = URLEncoder.encode(content+msg_key, "utf-8");
System.out.println(content);
String url = msg_ip+"corporateid="+msg_company_id+"&userid="+msg_user_id+"&password="+msg_pwd+"&mobile="+receiveMobile+"&content="+content+"&schtime=&subcode=";
URL urls = new URL(url);
HttpURLConnection connection = (HttpURLConnection) urls.openConnection();
//connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=gbk");
connection.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(),"utf-8"));//
String lines;
while ((lines = reader.readLine()) != null){
//lines = new String(lines.getBytes(), "utf-8");
System.out.println(lines);
}
reader.close();
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
try {
throw e;
} catch (Exception e1) {
e1.printStackTrace();
}
return 0;
}
return 1;
}
0 0
- 使用HttpURLConnection发送短信
- 使用HttpUrlConnection发送数据
- 使用HttpURLConnection发送数据
- 使用HttpURLConnection发送POST请求
- 使用HttpURLConnection发送HTTP请求
- 使用httpurlconnection发送http请求
- 使用Wininet发送短信
- 使用Wininet发送短信
- 使用Wininet发送短信
- 使用java发送短信
- 使用Wininet发送短信
- 使用web短信平台发送短信
- 使用名商通短信接口发送短信
- 如何使用短信猫发送中文短信
- 使用HttpURLConnection发送post和get请求
- 使用HttpURLConnection发送post和get请求
- 使用HttpURLConnection发送post和get请求
- 使用HttpURLConnection发送XML请求数据
- oj2010: C语言实验——逆置正整数
- PAT 乙级 1044. 火星数字(20) Java版
- 续照片人物:李济深,陈嘉庚,陈叔通
- java技术栈梳理
- magento中模块开发实例,前后台开发,前台表单提交,页面配置显示
- 使用HttpURLConnection发送短信
- java垃圾回收机制
- Ibatis批量插入
- 关于系统页面上的数据与数据库中数据一致性的测试(转)
- Python结合Pywinauto 进行 Windows UI 自动化
- 小数化为分数
- CDH5.7.2部署流程
- x264代码详解——主函数main()
- 【C++】学习笔记三十——函数参数和按值传递