이제 어떤 프로젝트를 사용하든 SMS 검증 함수를 사용하는 경우 SMS 검증 코드가 프로그램에 설계된 횟수에 대한 제한 사항이므로 주로 SMS Verification Code Interface가 브러시 링되는 것을 방지합니다.
이전 단락은 프로젝트에 대한 사용자 SMS 검증 코드의 로그인 기능으로 이루어 졌으므로 다음을 연구하고 아래에 게시하여 공유했습니다.
여기에 관련된 SMS 인터페이스는 타사 SMS 인터페이스 - 동적 사고 사고 (http://www.lx598.com/)를 사용합니다. SMS 인터페이스 액세스에 대해 알고 싶다면 공식 웹 사이트로 이동하여 SMS 인터페이스 API 문서 설명을 확인할 수 있습니다. 아래 코드를 참조하여 이해해야합니다.
사용자 등록 부분 인 기본 코드는 다음과 같습니다.
// main js method : // 모바일 검증 코드 가져옵니다 : function getRegcode () {if ($. trim ($ ( '##inputcaptcha'). val ()) {$ ( '#imgrs'). html ( "그래픽 검증 코드가 비어있을 수 없다"); $ ( '#inputcaptcha'). select (); 반품; } if (! isphonenum ($ ( '##phonere'). val ())) {document.getElementById ( 'phonereInfo'). innerHtml = '<font color = "red"> 유효한 11 자리 모바일 전화 번호 </font>'; } else {document.getElementById ( 'phonereInfo'). innerHtml = '등록 후 휴대폰 번호로 로그인'; $ .ajax ({url : "$ {path}/account/checkmob", type : "post", data : "account.accmob =" + $ ( '#phonere'). val (), contenttype : "application/x-www-form-urlencoded; charset = utf-8", async : async : as s (data) {res) getElementById ( 'phonereInfo'). innerhtml = '<font color = "red"> reftioyzm () {document.geteLementByid ('phonerenfo '). URL : "$ {path}/account/reaimcodegetVecode", type : "post", data : "acc : "application/x-form-urlencoded; charset = utf-8", Async : false, success (data) {myArray "Green"> 검증 코드가 전송되었습니다. else (data == 'getElementById). 경고 ( '예외, 검증 오류!'); } var smscount = parseint ($ ( '#smscount'). val ()); smscount = smscount <3? smscount+1 : 3; $ ( '#smscount'). val (smscount); } // 새 사용자를 등록 // 계정은 사용자 클래스 @Action (value = "reaimcodegetVecode") 공개 void reaimcodegetVecode () {printwriter out; 문자열 결과 = "검증 코드 응용 프로그램이 실패했습니다! 다시 시도하십시오!"; try {smsunit = new smsunit (confutil.getProperty ( "sys_sms_server")); if (null! = account.getAccmob () &&! account.getAccmob (). equals ( "")) {ac ac 계정 .setAcccreatedate (새 날짜 ()); Calendar C = Calendar.getInstance (); c.add (calendar.day_of_month, 1); // 검증 코드 만료 시간을 24 시간 계정으로 설정하십시오 .SetFregisterSource (FromSource); // 등록 소스 설정 // 휴대 전화가 검증 코드 계정 기준 계정 기준을 얻었는지 여부를 결정하십시오. AccountCriteria.CreateCriteria (). andaccmobequalto (account.getAccmob ()); List <cound> accs = ac // 확인 코드 수 요청 int re = 0; 정수 Cishu = 0; // 사용자가 존재하지 않는 경우 (accs == null || accs.isempty ()) {cishu = 1; 계정 .SETSDKURL ( "1"); ac // 검증 코드의 유효 시간을 설정 빅드 에미 먼 accid = accountservice.getPrimaryKey (); ac re = ac 쿠키 쿠키 = 새로운 쿠키 ( "id", accid.tostring ()); Cookie.SetMaxage (Integer.max_value); 응답 .addcookie (쿠키); } else {계정 ac = accs.get (0); accound.setfid (ac.getfid ()); 날짜 = 새 날짜 (); // 시간마다 검증 코드 수를 결정 // 새 날인 경우 사용 수를 1 If (date.getDate ()> = ac.getFsecurityOuttime (). getDate ()) {ac } else {integer count = integer.parseint (ac.getsdkurl ()); ac ac if (cishu <= 3) re = ac // 정보를 보내도록 확인 코드를 저장} if (re> 0 && cishu <= 3) {request.getSession (). removeAttribute (constValues.web_session_promote); AccountCriteria ac = 새 계정색 (); AC.CreateCriteria (). andaccmobequalto (account.getAccmob ()); <계정> aclist = new ArrayList <계정> (); ACLIST = AccountsErge.SelectByExample (AC); if (aclist! = null && aclist.size ()> 0) {// 여기에서 문자열 내용을 보내서 SMS 메시지를 실행합니다. sendsmsreply sendsmsreply = smsunit.sendsms (accname, accpwd, account.getaccmob (), content, ""); // SMS 결과를 보내기 위해 타사 인터페이스를 호출합니다 = sendsmsReply.getReplymsg () + "&" + aclist.get (0) .getFid () + "&"& " + aclist.get (0) .getDkurl (); }} else if (cishu> 3) {result = "제한된 응용 프로그램"; }}} catch (예외 e) {logger.error ( "검증 코드를 얻지 못했다", e); } 마침내 {try {response.setContentType ( "text/html; charset = utf-8"); 응답 .SetchAracterEncoding ( "UTF-8"); out = response.getWriter (); out.write (결과); } catch (ioexception e) {logger.error ( "", e); }}} // 이것은 전력 사고의 제 3 자 SMS 인터페이스의 SMS 기능을 전송하기위한 참조 코드입니다. Lexin : /*** SMS 보내기* @param accname lexin 계정 사용자 이름* @param accpwd lexin 계정 암호* @param seed 현재 시간 형식 : yyyyymmdd hhmiss for Example : 20130806102030* @param aim a im a ait a ait a ait a aircodes 여러 휴대 전화 번호간에 분리* @Param Content 컨텐츠 후 서명 추가* @Param Schtime Time Format : 2010-01-01 08:00:00* @Return 서버에서 반환 한 결과 : 비즈니스 ID 또는 오류 코드*/ public static string sendsms (문자열 accname, 문자열, 문자열 모비, 문자열 schtime) {stringbuffer sb = new StringBuffer ( "http://sdk.lx198.com/sdk/send2?"); try {string seed = new SimpledateFormat (dateformatstr) .format (new Date ()); sb.append ( "& accname ="+accname); sb.append ( "& seed ="+seed); sb.append ( "& accpwd ="+md5.getmd5string (md5.getmd5string (accpwd)+seed)); sb.append ( "& aimcodes ="+mobies); sb.append ( "& schtime ="+urlencoder.encode (schtime, "utf-8")); // 우주 구두점에서 변환 인코딩 sb.append ( "& content ="+urlencoder.encode (content, "utf-8")); // 중국 URL에서 변환을 인코딩합니다. New URL (sb.toString ()); httpurlConnection Connection = (httpurlConnection) url.openConnection (); Connection.setRequestMethod ( "post"); bufferedReader in = new bufferedReader (new inputStreamReader (url.openstream ())); return in.readline (); } catch (예외 e) {e.printstacktrace (); } return null; }위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.