注册波克城市推广员为什么还要往别人手机上发验证码玩法

8250人阅读
Java web(72)
JavaEE(45)
JavaSE(53)
Java(76)
注册发送手机验证码:
@RequestMapping(value = &/register/sendCode&, method = RequestMethod.POST)
public ResponseEntity&AjaxPostResponse& sendCode(HttpServletRequest request, HttpServletResponse response) {
String schoolId = this.getSchoolId(request);
String mobile = ServletRequestUtils.getStringParameter(request, &mobile&, &&).trim();
if (StringUtils.isBlank(mobile)) {
return this.errorResponse(&手机号不能为空&);
Pattern p = pile(&^((13[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$&);
Matcher m = p.matcher(mobile);
if (false == m.matches()) {
return this.errorResponse(&手机号格式不正确&);
User user = userManager.getUserByMobile(schoolId, mobile);
if (null != user) {
return this.errorResponse(&该手机号已注册&);
School school = schoolManager.getSchool(schoolId);
SchoolSettings schoolSettings = school.getSchoolSettingsBean();
Integer sendTime = 0; // 预防短信轰炸
sendTime = memcachedClient.get(&mobileCode_& + mobile) == null ? 0 : (Integer) memcachedClient.get(&mobileCode_& + mobile);
if (0 == sendTime) {
memcachedClient.add(&mobileCode_& + mobile, 30 * 60, sendTime); // 30 minutes
if (5 & sendTime) {
return this.errorResponse(&获取验证码次数过多&);
if (YesNoStatus.YES.getValue().equals(schoolSettings.getRegisterSetting())) {
String serviceURL = schoolSettings.getActivationMobileUrl();
String sn = schoolSettings.getActivationMobileSn();
String password = schoolSettings.getActivationMobilePassword();
String content = schoolSettings.getActivationMobileContent();
String code = PrimaryKeyUtils.generateRandomKey().substring(0, 4);
request.getSession().setAttribute(&mobile_code&+mobile, code);
content = content.replaceAll(&\\$\\{schoolName\\}&, school.getName());
content = content.replaceAll(&\\$\\{mobile\\}&, mobile);
content = content.replaceAll(&\\$\\{verificationCode\\}&, code);
MobileServerUtils.sendMobileCode(mobile, serviceURL, sn, password, content);
} catch (UnsupportedEncodingException e) {
(&RegisterController UnsupportedEncodingException&, e);
// 把请求验证码次数存储到MemCached中
String key = &mobileCode_& +
sendTime++;
memcachedClient.replace(key, 30 * 60, sendTime); // 30 minutes
} catch (Exception e) {
logger.warn(&把用户信息保存在Memcached中时发生异常,Cause: &, e);
return this.okResponse(true);
return this.errorResponse(&暂不开放注册&);
发送手机验证码的处理类:
package com.school.
import java.io.BufferedR
import java.io.ByteArrayOutputS
import java.io.InputStreamR
import java.io.OutputS
import java.io.UnsupportedEncodingE
import java.net.HttpURLC
import java.net.URL;
import java.net.URLC
import java.net.URLE
import java.security.MessageD
import java.security.NoSuchAlgorithmE
import java.util.regex.M
import java.util.regex.P
import org.slf4j.L
import org.slf4j.LoggerF
* 手机验证码工具类
* @author FeiFan Lin
public class MobileServerUtils {
private static final Logger LOG = LoggerFactory.getLogger(MobileServerUtils.class);
private String serviceURL = &&;
private String sn = &&; // 序列号
private String password = &&;
private String pwd = &&;// 密码
* 构造函数
private MobileServerUtils(String serviceURL, String sn, String password) throws UnsupportedEncodingException {
this.serviceURL = serviceURL;
this.password =
// 密码为md5(sn+password)
this.pwd = this.getMD5(sn + password);
* 发送验证码到手机
* @param mobile 手机号
* @param serviceURL 手机平台服务器地址
* @param sn 序列号
* @param password 密码
* @param content 内容
* @return 唯一标识
* @throws UnsupportedEncodingException
public static String sendMobileCode(String mobile, String serviceURL, String sn, String password, String content) throws UnsupportedEncodingException {
MobileServerUtils ms = new MobileServerUtils(serviceURL, sn, password);
content = URLEncoder.encode(content, &utf8&);
String result_mt = ms.mdsmssend(mobile, content, &&, &&, &&, &&);
return result_
* 方法名称:getMD5
能:字符串MD5加密
数:待转换字符串
* 返 回 值:加密之后字符串
private String getMD5(String sourceStr) throws UnsupportedEncodingException {
String resultStr = &&;
byte[] temp = sourceStr.getBytes();
MessageDigest md5 = MessageDigest.getInstance(&MD5&);
md5.update(temp);
// resultStr = new String(md5.digest());
byte[] b = md5.digest();
for (int i = 0; i & b. i++) {
char[] digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'A', 'B', 'C', 'D', 'E', 'F' };
char[] ob = new char[2];
ob[0] = digit[(b[i] &&& 4) & 0X0F];
ob[1] = digit[b[i] & 0X0F];
resultStr += new String(ob);
return resultS
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
* 方法名称:mdgetSninfo
能:获取信息
数:sn,pwd(软件序列号,加密密码md5(sn+password))
private String mdgetSninfo() {
String result = &&;
String soapAction = &/mdgetSninfo&;
String xml = &&?xml version=\&1.0\& encoding=\&utf-8\&?&&;
xml += &&soap:Envelope xmlns:xsi=\&http://www.w3.org/2001/XMLSchema-instance\& xmlns:xsd=\&http://www.w3.org/2001/XMLSchema\& xmlns:soap=\&http://schemas.xmlsoap.org/soap/envelope/\&&&;
xml += &&soap:Body&&;
xml += &&mdgetSninfo xmlns=\&/\&&&;
xml += &&sn&& + sn + &&/sn&&;
xml += &&pwd&& + pwd + &&/pwd&&;
xml += &&/mdgetSninfo&&;
xml += &&/soap:Body&&;
xml += &&/soap:Envelope&&;
url = new URL(serviceURL);
URLConnection connection = url.openConnection();
HttpURLConnection httpconn = (HttpURLConnection)
ByteArrayOutputStream bout = new ByteArrayOutputStream();
bout.write(xml.getBytes());
byte[] b = bout.toByteArray();
httpconn.setRequestProperty(&Content-Length&, String
.valueOf(b.length));
httpconn.setRequestProperty(&Content-Type&,
&text/ charset=gb2312&);
httpconn.setRequestProperty(&SOAPAction&, soapAction);
httpconn.setRequestMethod(&POST&);
httpconn.setDoInput(true);
httpconn.setDoOutput(true);
OutputStream out = httpconn.getOutputStream();
out.write(b);
out.close();
InputStreamReader isr = new InputStreamReader(httpconn
.getInputStream());
BufferedReader in = new BufferedReader(isr);
String inputL
while (null != (inputLine = in.readLine())) {
Pattern pattern = pile(&&mdgetSninfoResult&(.*)&/mdgetSninfoResult&&);
Matcher matcher = pattern.matcher(inputLine);
while (matcher.find()) {
result = matcher.group(1);
} catch (Exception e) {
e.printStackTrace();
return &&;
* 方法名称:mdgxsend
能:发送个性短信
数:mobile,content,ext,stime,rrid,msgfmt(手机号,内容,扩展码,定时时间,唯一标识,内容编码)
* 返 回 值:唯一标识,如果不填写rrid将返回系统生成的
private String mdgxsend(String mobile, String content, String ext, String stime,
String rrid, String msgfmt) {
String result = &&;
String soapAction = &/mdgxsend&;
String xml = &&?xml version=\&1.0\& encoding=\&utf-8\&?&&;
xml += &&soap:Envelope xmlns:xsi=\&http://www.w3.org/2001/XMLSchema-instance\& xmlns:xsd=\&http://www.w3.org/2001/XMLSchema\& xmlns:soap=\&http://schemas.xmlsoap.org/soap/envelope/\&&&;
xml += &&soap:Body&&;
xml += &&mdgxsend xmlns=\&/\&&&;
xml += &&sn&& + sn + &&/sn&&;
xml += &&pwd&& + pwd + &&/pwd&&;
xml += &&mobile&& + mobile + &&/mobile&&;
xml += &&content&& + content + &&/content&&;
xml += &&ext&& + ext + &&/ext&&;
xml += &&stime&& + stime + &&/stime&&;
xml += &&rrid&& + rrid + &&/rrid&&;
xml += &&msgfmt&& + msgfmt + &&/msgfmt&&;
xml += &&/mdgxsend&&;
xml += &&/soap:Body&&;
xml += &&/soap:Envelope&&;
url = new URL(serviceURL);
URLConnection connection = url.openConnection();
HttpURLConnection httpconn = (HttpURLConnection)
ByteArrayOutputStream bout = new ByteArrayOutputStream();
bout.write(xml.getBytes());
byte[] b = bout.toByteArray();
httpconn.setRequestProperty(&Content-Length&, String
.valueOf(b.length));
httpconn.setRequestProperty(&Content-Type&,
&text/ charset=gb2312&);
httpconn.setRequestProperty(&SOAPAction&, soapAction);
httpconn.setRequestMethod(&POST&);
httpconn.setDoInput(true);
httpconn.setDoOutput(true);
OutputStream out = httpconn.getOutputStream();
out.write(b);
out.close();
InputStreamReader isr = new InputStreamReader(httpconn
.getInputStream());
BufferedReader in = new BufferedReader(isr);
String inputL
while (null != (inputLine = in.readLine())) {
Pattern pattern = pile(&&mdgxsendResult&(.*)&/mdgxsendResult&&);
Matcher matcher = pattern.matcher(inputLine);
while (matcher.find()) {
result = matcher.group(1);
} catch (Exception e) {
e.printStackTrace();
return &&;
* 方法名称:mdsmssend
能:发送短信
* @param mobile 手机号
* @param content 内容
* @param ext 扩展码
* @param stime 定时时间
* @param rrid 唯一标识
* @param msgfmt 内容编码
* @return 唯一标识,如果不填写rrid将返回系统生成的
private String mdsmssend(String mobile, String content, String ext, String stime,
String rrid,String msgfmt) {
String result = &&;
String soapAction = &/mdsmssend&;
String xml = &&?xml version=\&1.0\& encoding=\&utf-8\&?&&;
xml += &&soap:Envelope xmlns:xsi=\&http://www.w3.org/2001/XMLSchema-instance\& xmlns:xsd=\&http://www.w3.org/2001/XMLSchema\& xmlns:soap=\&http://schemas.xmlsoap.org/soap/envelope/\&&&;
xml += &&soap:Body&&;
xml += &&mdsmssend
xmlns=\&/\&&&;
xml += &&sn&& + sn + &&/sn&&;
xml += &&pwd&& + pwd + &&/pwd&&;
xml += &&mobile&& + mobile + &&/mobile&&;
xml += &&content&& + content + &&/content&&;
xml += &&ext&& + ext + &&/ext&&;
xml += &&stime&& + stime + &&/stime&&;
xml += &&rrid&& + rrid + &&/rrid&&;
xml += &&msgfmt&& + msgfmt + &&/msgfmt&&;
xml += &&/mdsmssend&&;
xml += &&/soap:Body&&;
xml += &&/soap:Envelope&&;
url = new URL(serviceURL);
URLConnection connection = url.openConnection();
HttpURLConnection httpconn = (HttpURLConnection)
ByteArrayOutputStream bout = new ByteArrayOutputStream();
//bout.write(xml.getBytes());
bout.write(xml.getBytes(&GBK&));
byte[] b = bout.toByteArray();
httpconn.setRequestProperty(&Content-Length&, String
.valueOf(b.length));
httpconn.setRequestProperty(&Content-Type&,
&text/ charset=gb2312&);
httpconn.setRequestProperty(&SOAPAction&, soapAction);
httpconn.setRequestMethod(&POST&);
httpconn.setDoInput(true);
httpconn.setDoOutput(true);
OutputStream out = httpconn.getOutputStream();
out.write(b);
out.close();
InputStreamReader isr = new InputStreamReader(httpconn
.getInputStream());
BufferedReader in = new BufferedReader(isr);
String inputL
while (null != (inputLine = in.readLine())) {
Pattern pattern = pile(&&mdsmssendResult&(.*)&/mdsmssendResult&&);
Matcher matcher = pattern.matcher(inputLine);
while (matcher.find()) {
result = matcher.group(1);
} catch (Exception e) {
e.printStackTrace();
return &&;
跟通信运营商开通发短信服务:
&activationMobilePassword&: & 密码--通信运营商提供的
&activationMobileSn&: 序列号--通信运营商提供的
&activationMobileUrl&: 短信服务接口---通信运营商提供的
下面的是自己编辑的 短信的内容:验证码、
&activationMobileContent&:&${verificationCode} (${schoolName}注册验证码,五分钟内有效)【${schoolName}】&,
&forgotPasswordTitle&:&${nickname},请重置您${schoolName}的登录密码&,
&forgotPasswordContent&:&Hi, ${nickname} \r
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:850569次
积分:12857
积分:12857
排名:第1203名
原创:407篇
转载:23篇
评论:182条
(2)(8)(7)(3)(12)(3)(7)(3)(5)(6)(1)(3)(12)(9)(5)(2)(5)(13)(21)(12)(5)(8)(8)(6)(6)(4)(16)(18)(7)(5)(9)(7)(7)(5)(4)(8)(10)(6)(13)(8)(4)(11)(15)(11)(17)(14)(7)(13)(12)(12)(19)(1)
(window.slotbydup = window.slotbydup || []).push({
id: '4740887',
container: s,
size: '250,250',
display: 'inlay-fix'手机突然莫名其妙收到网易短信,发了个验证码来
我自己并没有上网做任何操作,是不是我啥账号被盗了
[img]./mon_/-7Q2g-seK14T3cSmf-13u.png[/img]
是别人注册什么东西一不小心填成你得手机号了估计
不用紧张,一般都是别人输错手机号导致的。。我自己就输错了几次。
有可能别人手机号和你只差一位正好打错了但小心为上,不要任何途径透露这个验证码就好,最好马上删掉且不说手机上的app有没有病毒,万一你附近的人能接触你手机,有些事就不好说了
只有一条那是别人填错填你手机号了。若是N多条,那就是短信轰炸了。
原来是这样,还以为被盗号了
[b]Reply to [pid=]Reply[/pid] Post by [uid=]Fittich[/uid] ( 15:36)[/b]多谢提醒,已经删掉了网站注册会员手机绑定需要发送验证码到手机怎么实现? 知道的说下,_百度知道
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。
网站注册会员手机绑定需要发送验证码到手机怎么实现? 知道的说下,
最好给个例子。谢谢了。
我有更好的答案
网站这块一般都好解决,最重要的 验证码要发送到手机上,要通过短信通道发送。一般正规的行业短信服务商要求哈,一直都在为大客户提供这个验证码短信通道,我告诉你怎么实现很简单的,了解需求洽谈----签订合同-----提交资料申请通道和签名(运营商强制要求签名避免垃圾短信),网站上判断是否一致,提供接口参数链接到你的网站,这些是网站这边需要做好接口,一致则通过注册、首先您网站注册时需要输入手机网页代码写好,客户输入手机后点获取验证码,您这里会随机生成验证码,然后通过短信通道提交到运营商服务器,运营商把验证码发送到客户手机上,客户输入到网站上,---------技术对接。---测试使用----正常使用----售后服务。1。2
采纳率:38%
为您推荐:
其他类似问题
手机绑定的相关知识
换一换
回答问题,赢新手礼包绑定手机操作时如果很长时间都没有收到验证码怎么办?
这种情况可能是由于移动或者联通等运营商网关繁忙造成的系统延迟,建议您可以耐心等待一下,如果长时间未收到验证码,也可以利用要绑定的手机直接联系一下我们的客服热线021-进行相关咨询!
Copyright&&&网络科技(上海)有限公司
增值电信业务经营许可证
网络文化经营许可证
沪ICP备号-10
| 科技与数字[号
文网游备字(2011)C-CBG015号
ISBN:978-7--4注册波克城市为什么还要往别人手机上发验证码_百度知道
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。
注册波克城市为什么还要往别人手机上发验证码
我有更好的答案
你是不是在手机上注册的,他会自动识别手机号码进行注册的,就是为了卡号与游戏一体化,其实是为了方便用户,如何去查询帐号也比较方便。你如果想不发短信的,可以到他们官网去注册了
采纳率:77%
应该是为了安全吧
为您推荐:
其他类似问题
波克城市的相关知识
换一换
回答问题,赢新手礼包

我要回帖

更多关于 波克城市斗地主 的文章

 

随机推荐