码迷,mamicode.com
首页 > 其他好文 > 详细

发送短信

时间:2014-06-11 11:31:29      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   java   http   

bubuko.com,布布扣
//get 发送短信
    public static String send_sms(String mobile_phone, String msg) {
        String ret_str = "";
        BufferedReader rd=null;
        try {
            String send_content=URLEncoder.encode(msg.replaceAll("<br/>", " "), "GBK");//发送内容
            String myurl=getPropertiesByKey("sms_get")+"?CorpID="+
                      getPropertiesByKey("sms_userId")+"&Pwd="+getPropertiesByKey("sms_password")
                      +"&Cell=&SendTime=&Mobile="+mobile_phone+"&Content="+ send_content;
            
            
            System.out.println("send sms url:"+myurl);
            
         //System.out.println(myurl);
          URL url = new URL(myurl);
          URLConnection conn = url.openConnection();
          conn.setDoOutput(true);
        // Get the response
            rd = new BufferedReader(new InputStreamReader(conn.
              getInputStream()));
          String line;
          while ( (line = rd.readLine()) != null) {
              ret_str += line;
          }
          rd.close();
        }
        catch (Exception e) {
          System.out.println(e.toString());
          ret_str="2";
        }
        finally{
            try {
                if(rd!=null)
                  rd.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        System.out.println("发送短信返回值:"+ret_str);
        return ret_str;
         
    }
bubuko.com,布布扣

 

发送短信,布布扣,bubuko.com

发送短信

标签:style   class   blog   code   java   http   

原文地址:http://www.cnblogs.com/W203654/p/3772743.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!