package com.jeeplus.common.utils;
import java.io.UnsupportedEncodingException;
import net.sf.json.JSONObject;
@SuppressWarnings("unused")
public class CallPublicServiceUtils {
private final static String PublicSendShortMessage = "publicService/publicSendShortMessage.htm";
private static PropertiesLoader loader = new PropertiesLoader("jeeplus.properties");
public static String pUrl() {
return loader.getProperty("publicServiceUrl");
}
/**
* 给用户发短信接口
* @param content 短信内容
* @param calledTel 手机号
* @param code 模板编号
* @return
* @throws UnsupportedEncodingException
*/
public static JSONObject publicSendShortMessage(String content, String calledTel, String code) throws UnsupportedEncodingException {
content = new String(content.getBytes("utf-8"), "gbk");//因为用户收到的短信可能含有乱码,所以需要将此处文本的字符串编码改变到与发送短信的服务器的编码一致
String result = CallUrlUtil.sendPost(pUrl() + PublicSendShortMessage, "content=" + content + "&calledTel=" + calledTel + "&code=" + code);
JSONObject json = new JSONObject();
json = JSONObject.fromObject(result);
return json;
}
}
解决发送短信内容乱码
最新推荐文章于 2023-11-17 11:34:57 发布