cy
2022-06-23 b83c40548208609d0d6826be13d742c28a784806
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package cn.ksource.core.util;
 
import cn.ksource.web.Constants;
import org.apache.log4j.Logger;
 
import java.util.HashMap;
import java.util.Map;
 
public class TestFgcx {
    private static Logger logger = Logger.getLogger(SMSUtil.class);
    //发送短信信息接口接入用户名
    public static String account = "418928999";
    //发送短信信息接口接入密码
    public static String pwd = "123123";
    //发送短信接口地址
    public static String interfaceUrl = "http://dx.it1199.com:83/ApiService.asmx/Send";
    
    //产品编号
    public static String product = "6";
    //编码类型
    public static HttpCharset charset = HttpCharset.UTF8;
    
    
    //余额查询接口地址
    public static String balanceUrl = "http://116.213.72.20/SMSHttpService/Balance.aspx";
    
    /**
     * 发送短信
     * @param address 接收信息的号码
     * @param message 发送信息内容
     * @return
     * @throws Exception
     */
    public static String sendSMS(String address, String message) throws Exception {
        logger.info("向手机号:" + address + "发送短信内容:\"" + message + "\"");
        System.out.println("客户端-向手机号:" + address + "发送短信内容:\"" + message + "\"");
        Map params = new HashMap();
        params.put("account", account);
        params.put("pwd", pwd);
        params.put("message", message);
        params.put("mobile", address);
        params.put("product", product);
        String result = HttpUtil.doPost(interfaceUrl, params, charset);
        logger.info("返回信息:" + result);
        return result;
    }
    
    
    
    public static void main(String[] args) {
        try {
            //sendSMS("15803816250", "123456测试联通短信");
            sendSMS("15803816250,18637173833","您好,通过本次检查,您的设备运行一切正常,请放心。【"+ Constants.company_name+"服务】");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}