如何实现网站短信验证,实现手机号验证

yong6485780 2013-12-06 03:38:03
怎么实现网站上输入手机号,然后手机收到验证码,在输入验证码,从而绑定手机号
...全文
958 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yong6485780 2013-12-06
  • 打赏
  • 举报
回复
引用 2 楼 huxiweng 的回复:
用第三方短信提供商 我们项目用的是:http://www.smschinese.cn/api.shtml
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="java.net.*" import="java.io.*" errorPage=""%> <%@page import="java.io.DataInputStream"%> <%@ page import='com.xianxia.been.MD5'%> <% //用户ID和KEY String UserId = ""; String key = ""; String phone = request.getParameter("Tel"); MD5 md5 = new MD5(); String pwdmd5 = md5.getMD5ofStr(UserId + "0" + phone + key); String curlPost = "UserId=" + URLEncoder.encode(UserId, "UTF-8") + "&phone=" + URLEncoder.encode(phone, "UTF-8") + "&Md5Str=" + URLEncoder.encode(pwdmd5, "UTF-8"); URL url = null; HttpURLConnection httpurlconnection = null; try { url = new URL("http://106.ihuyi.com/webservice/sms.php?"); //url = new URL("http://127.0.0.1:81/webcode/outcallInterface.php"); httpurlconnection = (HttpURLConnection) url.openConnection(); httpurlconnection.setDoOutput(true); httpurlconnection.setRequestMethod("POST"); httpurlconnection.setRequestProperty("Connection", "Keep-Alive"); httpurlconnection.setRequestProperty("Content-Type ", "application/x-www-form-urlencoded "); httpurlconnection.getOutputStream().write( curlPost.getBytes("UTF-8")); httpurlconnection.getOutputStream().flush(); httpurlconnection.getOutputStream().close(); DataInputStream is = new DataInputStream(httpurlconnection .getInputStream()); BufferedReader reader = new BufferedReader( new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line); } } catch (IOException e) { } finally { try { is.close(); } catch (IOException e) { } } String authcode = sb.toString(); // out.print(authcode); if (authcode.length() > 1) { session.setAttribute("code", authcode); out.print("ok"); return; } else { out.print("error"); return; } } catch (Exception e) { //e.printStackTrace(); } finally { if (httpurlconnection != null) { httpurlconnection.disconnect(); } } %> 这样可以吗
soyestrellafortuna 2013-12-06
  • 打赏
  • 举报
回复
有短信平台的
___________小P 2013-12-06
  • 打赏
  • 举报
回复
用第三方短信提供商
teemai 2013-12-06
  • 打赏
  • 举报
回复
用第三方短信提供商 我们项目用的是:http://www.smschinese.cn/api.shtml
淡淡的蛋蛋 2013-12-06
  • 打赏
  • 举报
回复
最简单的事有专门的平台

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧