zoukankan      html  css  js  c++  java
  • 发送短信

    //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;
             
        }

    宝贝网址:

  • 相关阅读:
    频率计数器简介
    电力时钟厂家简介
    linux mail命令详解
    /etc/postfix下 main.cf 配置文件详解
    linux tar
    Linux find命令详解
    Python with
    Python 多进程概述
    python paramiko模块简介
    python 全局变量和局部变量
  • 原文地址:https://www.cnblogs.com/W203654/p/3772743.html
Copyright © 2011-2022 走看看