package com.izouma.awesomeadmin.util;

import java.io.IOException;
import java.net.URLEncoder;

import org.apache.log4j.Logger;
import org.springframework.util.DigestUtils;

/**
 * 
 * <p>微信接入校验。</p> 
 * 
 * @version 1.0
 * @author 姓名 <br />
 * 更新履历 <br />
 *  日期 : 姓名: 更新内容<br />
 */
public class MsgUtil {

    private static Logger log        = Logger.getLogger(MsgUtil.class);

    public static String  sendSmsUri = "http://58.83.147.92:8080/qxt/smssenderv2";

    public static String  user       = "zs_taishang";

    public static String  password   = "taishang";


    public static String sendSms(String phone, String message) throws IOException {

        String result = null;
        String param = "user=" + user + "&password=" + DigestUtils.md5DigestAsHex(password.getBytes()) + "&tele=" + phone + "&msg="
                + URLEncoder.encode(message, "GBK") + "&extno=1";
        try {
            result = NetUtils.getUrlResponse(sendSmsUri, param);
        } catch (Exception e) {
            log.error("", e);
            throw e;
        }
        return result;
    }

}
