| | |
| | | package com.project.common.sms; |
| | | |
| | | import com.project.common.constant.Constants; |
| | | import com.project.common.utils.SslUtils; |
| | | import org.apache.http.HttpEntity; |
| | | import org.apache.http.NameValuePair; |
| | | import org.apache.http.client.entity.UrlEncodedFormEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.message.BasicNameValuePair; |
| | | import org.apache.http.util.EntityUtils; |
| | | |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static com.project.common.utils.WxPayUtils.createIgnoreSSLHttpClient; |
| | | |
| | | /** |
| | | * 短信http接口的java代码调用示例 |
| | |
| | | public class YPSmsApi { |
| | | |
| | | /** |
| | | * 请求地址 |
| | | * 智能匹配模板发送地址 |
| | | */ |
| | | private static final String YP_SMS_URI = "http://yunpian.com/v1/sms/send.json"; |
| | | private static final String YP_SMS_URI = "https://sms.yunpian.com/v2/sms/single_send.json"; |
| | | |
| | | /** |
| | | * 模板发送地址 |
| | | */ |
| | | private static final String YP_SMS_TMP_URI = "https://sms.yunpian.com/v2/sms/tpl_single_send.json"; |
| | | |
| | | /** |
| | | * KEY |
| | |
| | | private static final String SIGN = "【金明源】"; |
| | | |
| | | /** |
| | | * 执法单申请模板 |
| | | */ |
| | | public static final String APPLY_TMP = "{} 提交了新的申请单,请您及时审批!"; |
| | | |
| | | /** |
| | | * 执法单审核后模板 |
| | | */ |
| | | public static final String CHECK_TMP = "您提交的申请单已被审批人 {}, 请您及时查看!"; |
| | | |
| | | /** |
| | | * 企业通知模板 |
| | | */ |
| | | public static final String COMPANY_TMP = "{} 单位预计将于 {} 到贵单位进行检查,请提前知晓!"; |
| | | |
| | | /** |
| | | * 验证码模板 |
| | | */ |
| | | public static final String VERIFY_CODE_TEMPLATE = "您的验证码是{}"; |
| | | public static final String CODE_TMP = "您的验证码是{}"; |
| | | |
| | | /** |
| | | * 审批通知模板 |
| | | */ |
| | | public static final String CHECK_NOTICE_TEMPLATE = SIGN + "{}提交了执法申请单,请您及时审批!"; |
| | | |
| | | /** |
| | | * 审批通过模板 |
| | | */ |
| | | public static final String CHECK_PASS_TEMPLATE = SIGN + "您提交的执法申请单已审批通过,请您及时查看!"; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 发送短信 |
| | | * 简单发送短信 |
| | | * @param mobile 接受的手机号 |
| | | * @param msg 短信内容 |
| | | */ |
| | |
| | | */ |
| | | public static String post(String url, Map<String, String> paramsMap) |
| | | { |
| | | CloseableHttpClient client = HttpClients.createDefault(); |
| | | CloseableHttpClient client = createIgnoreSSLHttpClient(); |
| | | |
| | | String responseText = ""; |
| | | CloseableHttpResponse response = null; |
| | | try { |
| | | |
| | | HttpPost method = new HttpPost(url); |
| | | if(method.getURI().getPath().contains("https")){ |
| | | SslUtils.ignoreSsl(); |
| | | } |
| | | if (paramsMap != null) { |
| | | List<NameValuePair> paramList = new ArrayList<NameValuePair>(); |
| | | for (Map.Entry<String, String> param : paramsMap.entrySet()) { |