java 短信接口开发
来源:互联网 发布:手机桌面优化软件 编辑:程序博客网 时间:2024/05/24 00:05
<pre name="code" class="java">import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.net.HttpURLConnection;import java.net.URL;public class Send { public static String SMS(String postData, String postUrl) { try { //发送POST请求 URL url = new URL(postUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setUseCaches(false); conn.setDoOutput(true); conn.setRequestProperty("Content-Length", "" + postData.length()); OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8"); out.write(postData); out.flush(); out.close(); //获取响应状态 if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { System.out.println("connect failed!"); return ""; } //获取响应内容体 String line, result = ""; BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8")); while ((line = in.readLine()) != null) { result += line + "\n"; } in.close(); return result; } catch (IOException e) { e.printStackTrace(System.out); } return ""; }}
import java.io.UnsupportedEncodingException;public class SendMessage {public String sendmessage(String phone) {String PostData;phone="110";try {PostData = "SpCode=asdfa&SerialNumber=12121212121212121212&LoginName=sadf&"+ "Password=sdafas%&UserNumber="+phone+"&MessageContent="+java.net.URLEncoder.encode("您的验证码为12321","utf-8"); System.out.println(PostData); String ret = DAO.Send.SMS(PostData, "http://sms.api.ums86.com:8899/sms/Api/Send.do"); System.out.println(ret); return "sendsuccess"; } catch (UnsupportedEncodingException e) {e.printStackTrace();return e.toString();}}}
0 0
- 短信JAVA开发接口
- java 短信接口开发
- java短信发送接口开发
- mas2.0 java 短信/彩信开发接口
- 贝贝短信开发接口
- node短信接口开发
- 短信发送接口开发
- Java短信接口开发经验及具体开发实现
- Java 短信接口源码
- java短信接口调用
- java短信接口调用
- java短信接口
- java实现短信接口
- 短信网关接口开发技术
- 北京短信二次接口开发
- 团购网的短信接口开发
- 面向短信接口开发实例
- 短信二次接口开发demo
- byte数组和文件互相转换
- VRRP协议
- NYOJ 115 城市平乱【Dijkstra】
- linux下设计一个Shell脚本:求命令行上所有整数和
- 安装PostgreSQL数据库(Linux篇)
- java 短信接口开发
- CentOS 7系统远程会话管理工具screen怎么安装使用
- 整理 collectionView 瀑布流 布局
- linux下设计一个Shell脚本:判断当前工作目录下所有的文件类型。
- java jni 入门7 - 访问数组元素
- iOS中的协议与延展
- 杭电-4545魔法串(LCS)
- 属性动画之ValueAnimator
- [LeetCode283]Move Zeroes