极光验证码的用法
来源:互联网 发布:法国旅游 知乎 编辑:程序博客网 时间:2024/06/03 19:57
package com.champion.itax.common.util;import cn.jiguang.common.resp.APIConnectionException;import cn.jiguang.common.resp.APIRequestException;import cn.jsms.api.SendSMSResult;import cn.jsms.api.common.SMSClient;import cn.jsms.api.common.model.SMSPayload;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import javax.servlet.http.HttpServletRequest;import java.util.Random;import java.util.ResourceBundle;/** * Created by wen on 2017/7/20. */public class sendVcodeUtil { private static Logger LOG = LoggerFactory.getLogger(sendVcodeUtil.class); public static String sendcode(String telephone, HttpServletRequest request) {/* try { JSMSClient jsc = new JSMSClient("bfbeb49dd87971ea564a3398", "52f167a881f3a59a5175580d"); SMSClient cl = jsc.getSMSClient(); Map<String, String> paramap = new HashMap<String, String>(); String vCode=Integer.toString(getMember()); request.getSession().setAttribute("vCode",vCode); paramap.put("code",vCode ); Builder builder = new Builder(); builder.setMobildNumber(telephone); builder.setTempId(127604); builder.setTTL(2); builder.setTempPara(paramap); SMSPayload spl = builder.build(); SendSMSResult rs = cl.sendTemplateSMS(spl);// ValidSMSResult vrs = cl.sendValidSMSCode(rs.getMessageId(), "333333"); System.out.println(rs.getResponseCode()); System.out.println(rs.getOriginalContent()); } catch (APIConnectionException e) { e.printStackTrace(); } catch (APIRequestException e) { e.printStackTrace(); }*/ ResourceBundle bundle = ResourceBundle.getBundle("sms"); String masterSecret= bundle.getString("masterSecret"); String appkey=bundle.getString("appkey"); String tempId=bundle.getString("tempId"); SMSClient client = new SMSClient(masterSecret, appkey); String vCode=Integer.toString(getMember()); request.getSession().setAttribute("vCode",vCode); SMSPayload payload = SMSPayload.newBuilder() .setMobildNumber(telephone) .setTempId(Integer.parseInt(tempId)) .addTempPara("code",vCode) .build(); try { SendSMSResult res = client.sendTemplateSMS(payload); LOG.info(res.toString()); } catch (APIConnectionException e) { LOG.error("Connection error. Should retry later. ", e); } catch (APIRequestException e) { LOG.error("Error response from JPush server. Should review and fix it. ", e); LOG.info("HTTP Status: " + e.getStatus()); LOG.info("Error Message: " + e.getMessage()); } return null; } public static int getMember(){ int x;//定义两变量 Random ne=new Random();//实例化一个random的对象ne x=ne.nextInt(9999-1000+1)+1000;//为变量赋随机值1000-9999 return x; }}
阅读全文
0 0
- 极光验证码的用法
- 极光短信验证码的集成过程
- Android极光推送集成以及极光验证码注册Demo
- 关于JPsh极光推送的基本用法和通知介绍
- 极光推送(短信验证)
- 一个MVC4 下的验证码用法
- thinkphp3.2.1验证码的用法
- extjs的验证用法
- 耶洛奈夫上空的极光
- 美丽的极光
- 极光推送的使用方法
- 极光推送的设置
- 极光推送的API
- 极光推送的使用
- 极光推送的使用
- 极光推送的使用
- 极光推送的使用
- 极光推送的常见问题
- mysql数据库上传csv数据小问题解决
- springmvc前端控制器的配置
- Linux下的工作模型以及Nginx工作原理
- 交换两个整形变量的值(不能创建临时变量)
- 文本转成音频,C#
- 极光验证码的用法
- QT 012 [深入] Qt setupUi函数的原理和实现
- 获取单选框/复选框选中值
- 51nod--1050 循环数组最大字段和
- 导入一个AndroidStudio工程作为一个Library Module
- POJ-1426 Find The Multiple
- 从施奈德曼谈人机交互学科发展看创新的必由之路
- Activity的onNewIntent
- java保留两位小数4种方法