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

    以建周短信平台为例

    package com.wjz.util;
    
    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.HttpStatus;
    import org.apache.commons.httpclient.methods.PostMethod;
    
    public class SMSUtil {
    
        /**
         * 
         * @param url
         *            短信平台地址
         * @param phone
         *            目标手机
         * @param message
         *            短信内容
         * @param account
         *            动态获取短信平台账号如从数据库中获得
         * @param password
         *            动态获取短信平台密码如从数据库中获得
         * @return
         */
        public static String send(String url, String phone, String message, String account, String password) {
            HttpClient httpClient = new HttpClient();
            PostMethod postMethod = new PostMethod(url);
            postMethod.getParams().setContentCharset("UTF-8");
            postMethod.addParameter("account", account);
            postMethod.addParameter("password", password);
            postMethod.addParameter("destmobile", phone);
            postMethod.addParameter("sendDateTime", "");
            postMethod.addParameter("msgText", message);
    
            String responseMsg = null;
            try {
                int code = httpClient.executeMethod(postMethod);
                if (code == HttpStatus.SC_OK) {
                    responseMsg = postMethod.getResponseBodyAsString();
                }
            } catch (Exception e) {
                // 
            } finally {
                postMethod.releaseConnection();
            }
            return responseMsg;
        }
    
    }
  • 相关阅读:
    格式布局
    hive UDAF源代码分析
    HIVE自定义函数 UDF
    HIVE函数UDAF 最大值
    牛顿法求平方根 scala
    mongoDB
    java类的加载机制
    类的加载过程
    Redis学习手册(目录)
    我与小娜(05):变换时空,重返北京
  • 原文地址:https://www.cnblogs.com/BINGJJFLY/p/7484438.html
Copyright © 2011-2022 走看看