首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

java短信接口—包括get交付

2012-10-29 
java短信接口—包括get提交java短信接口程序(get提交)import java.io.BufferedReaderimport java.io.Input

java短信接口—包括get提交

java短信接口程序(get提交)

import java.io.BufferedReader;import java.io.InputStreamReader;import java.net.HttpURLConnection;import java.net.URL;import java.net.URLEncoder;//http://admin.sm9.cn/houtai/sms.php?cccid=123456&password=123456&gateId=1&tele=13800138000,13101234567&msg=testcontentpublic class sendMsg {private String cccid = "userName";// 企业用户名private String password = "password";// 企业密码private String gateId = "1";// 通道选择public String sendMessage(String phone, String msg) {String result = null;HttpURLConnection httpconn = null;StringBuffer sb = new StringBuffer();sb.append("http://admin.sm9.cn/houtai/sms.php?cccid=");sb.append(cccid);sb.append("&password=");sb.append(password);sb.append("&gateId=");sb.append(gateId);sb.append("&tele=");sb.append(phone);sb.append("&msg=");try {sb.append(URLEncoder.encode(msg, "gbk"));URL url = new URL(sb.toString());httpconn = (HttpURLConnection) url.openConnection();BufferedReader rd = new BufferedReader(new InputStreamReader(httpconn.getInputStream()));result = rd.readLine();rd.close();} catch (Exception e) {e.printStackTrace();} finally {if (httpconn != null) {httpconn.disconnect();httpconn = null;}}return result;}}                                                                                                                                                                         

热点排行