精华内容
下载资源
问答
  • 然后结合iv和encryptedData解密出微信用户手机号码【操作步骤】第1步:wx.login获取code第2步:传递code到服务器,获取session_key和openid第3步:参考官方文档getPhoneNumber,获取iv和encryptedData第4步:解密...
  • java解析的源码和小程序的源码,自己从项目中剥离出来的,肯定能用,有疑问私信,微信小程序获取各类信息(openid、session_key以及用户基本信息、解密手机号
  • 场景: 用户已经绑定手机,在这种情况下我需要通过短信验证 原来得手机号码是否正确然后还要验证新号码是否正确 但是这两种方法不能写在一个接口上,请问一下大家这是怎么做的
  • Java获取微信用户绑定手机号

    千次阅读 2019-07-23 17:18:03
    return Result.newFailure(-1, "获取手机号异常失败"); } } 遇到的错误: javax.crypto.BadPaddingException: Given final block not properly pad java.security.NoSuchAlgorithmException: Cannot ...

    微信官方文档  https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html

    全部放在一个Controller里了,方便看。代码中有些是自定义封装的工具类,关键部分就是try代码块中解密的用法。

        @RequestMapping(rootUrl + "decodeWxAppPhone")
        @ResponseBody
        public Object decodeWxAppPhone(HttpServletRequest request,
                HttpServletResponse response) {
            response.setHeader("Access-Control-Allow-Origin", "*");
            ResResult verResult = CommonSignUtils.verifyParamAndPermission(request,
                    "encrypted,iv,code");
            if (ObjectHelper.isNotEmpty(verResult.getResObject())) {// 验证未通过
                return verResult.getResObject();
            }
            String encrypted = verResult.getParams().get("encrypted");
            String iv = verResult.getParams().get("iv");
            String code = verResult.getParams().get("code");
            Map<String, String> params = new HashMap<>();
            params.put("appid", appId);
            params.put("secret", secret);
            params.put("js_code", code);
            params.put("grant_type", "authorization_code");
            try {
                // 向微信服务器发送post请求获取加密了的内容   
                String jsonStr= HTTPSocketFactory
                        .postHttp2("https://api.weixin.qq.com/sns/jscode2session",
                                params)
                        .getObject();
                JSONObject jsonObject = JSON.parseObject(jsonStr);
                String sessionkey = jsonObject.getString("session_key");
                // 解密
                byte[] encrypData = Base64Utils.decodeFromString(encrypted);
                byte[] ivData = Base64Utils.decodeFromString(iv);
                byte[] sessionKey1 = Base64Utils.decodeFromString(sessionkey);
                AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivData);
                //java中自带的是PKCS5Padding填充,通过添加BouncyCastle组件来支持PKCS7Padding填充。
                Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
                Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
                SecretKeySpec keySpec = new SecretKeySpec(sessionKey1, "AES");
                cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
                String resultString = new String(cipher.doFinal(encrypData), "UTF-8");
                JSONObject object = JSONObject.parseObject(resultString);
                // 拿到手机号码
                String phone = object.getString("phoneNumber");
                JSONObject returnObject = new JSONObject();
                returnObject.put("phone", phone);
                return Result.newSuccess(returnObject);
            } catch (Exception e) {
                e.printStackTrace();
                return Result.newFailure(-1, "获取手机号异常失败");
            }
        }

    遇到的错误:

    javax.crypto.BadPaddingException: Given final block not properly pad

    java.security.NoSuchAlgorithmException: Cannot find any provider supporting AES/CBC/PKCS7Padding

    java.security.InvalidAlgorithmParameterException: ECB mode cannot use IV

    java.lang.IllegalArgumentException: Last unit does not have enough valid bits

    javax.crypto.BadPaddingException: pad block corrupted

    偶尔报:javax.crypto.BadPaddingException: pad block corrupted

    并且运行到这一句报的错:Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding","BC");

    https://blog.csdn.net/zhanglf02/article/details/100124091

    参考博客:

    [1] https://blog.csdn.net/yuanhangLVli/article/details/82152178

    [2] https://www.jianshu.com/p/2853b21fb42e

    [3] https://blog.csdn.net/dywailly/article/details/46861777

    [4] https://www.jianshu.com/p/f8cd7391d641

    展开全文
  • JAVA服务端解密与微信绑定手机号 背景介绍 在前段时间公司开发小程序的项目中,服务端需要配合前端获取当前用户与微信绑定手机号;需要以下两步: 1.根据前端所传的code通过服务端调微信接口获取openId,...

    JAVA服务端解密与微信绑定的手机号

    背景介绍

    在前段时间公司开发小程序的项目中,服务端需要配合前端获取当前用户与微信绑定的手机号;需要以下两步:
    1.根据前端所传的code通过服务端调微信接口获取openId,sessionkey;
    2.根据前端所传的encrypdata,ivdata,sessionKey服务端进行解密后得到手机号

    前提工作

    首先在微信公众平台申请小程序公众号,申请成功后就能获取到 appid 和 secret两参数

    代码展示

    获取微信openId sessionKey

    参数:
    code:为前端传入
    MINI_PROGRAM_REQUEST_URL :https://api.weixin.qq.com/sns/jscode2session
    MINI_PROGRAM_APPID:小程序appid
    MINI_PROGRAM_SECRET :小程序secret

    /**
         *  <desc>
         *      获取微信openId sessionKey
         *  </desc>
         *
         * @param code 微信参数
         * @return
         * @createDate 2018/12/7
         */
        @RequestMapping(path = "/getOpenId",method = RequestMethod.POST)
        @ResponseBody
        public MessageVO getOpenId(String code){
            Map<String, Object> map = new HashMap<>();
            String status = "1";
            String msg = "ok";
            String requestUrl = MINI_PROGRAM_REQUEST_URL +"?appid="+MINI_PROGRAM_APPID+"&secret="+MINI_PROGRAM_SECRET+"&js_code="+code+"&grant_type=authorization_code";
            try {
                if(StringUtils.isBlank(code)){
                    status = "0";//失败状态
                    msg = "code为空";
                }else {
                    System.out.println(requestUrl);
                    // 发起GET请求获取凭证
                    JSONObject jsonObject = HttpProtocolUtil.httpsRequest(requestUrl, "GET", null);
                    if (jsonObject != null) {
                        try {
                            map.put("openid", jsonObject.getString("openid"));
                            map.put("session_key", jsonObject.getString("session_key"));
                        } catch (JSONException e) {
                            // 获取token失败
                            status = "0";
                            msg = "code无效";
                        }
                    }else {
                        status = "0";
                        msg = "code无效";
                    }
                }
                map.put("status", status);
                map.put("msg", msg);
            } catch (Exception e) {
                throw new DataAccessException("【小程序】获取openId失败",e);
            }
            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),map);
        }
    

    解密与微信绑定的手机号

    /**
         *  <desc>
         *      解密与微信绑定的手机号
         *  </desc>
         *
         * @param encrypdata 微信参数
         * @param ivdata 微信参数
         * @param sessionKey 会话密钥
         * @return
         * @createDate 2018/11/24
         */
        @RequestMapping(path = "/getPhoneNum",method = RequestMethod.POST)
        @ResponseBody
        public MessageVO getPhoneNum(String encrypdata,String ivdata,String sessionKey){
            try {
                if(StringUtils.isEmpty(encrypdata) || StringUtils.isEmpty(ivdata) || StringUtils.isEmpty(sessionKey)){
                    return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
                }
                byte[] encrypData = Base64.decode(encrypdata);
                byte[] ivData = Base64.decode(ivdata);
                byte[] sessionKeyByte = Base64.decode(sessionKey);
                AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivData);
                Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
                SecretKeySpec keySpec = new SecretKeySpec(sessionKeyByte, "AES");
                cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
                //解析解密后的字符串 
                String phoneNum = new String(cipher.doFinal(encrypData),"UTF-8");
    
                return  new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),phoneNum);
            }catch (Exception e){
                throw new DataAccessException("【小程序_注册登录版块】解密与微信绑定的手机号失败",e);
            }
        }
    
    展开全文
  • java微信绑定

    千次阅读 2018-07-11 15:27:54
    手机号: label > < span > ${login_user.phone} span > div > < div class = "text-left user-info" > < label > QQ号 : label > < span > ${login_user.qq} span > div > div >...

    参考: 1.https://www.cnblogs.com/martianShu/p/5947170.html
    基本上看了这篇文章,就可以了,前提是要看一下微信开发文档,申请微信开发公众号等,前期准备要做好

    1. 申请微信公众号 ,获得公众号的appid和秘钥
    2. 查看appid及appsecret

    3. 前台引入相关js

    <script type="text/javascript" src="${base}/theme2/plugins/jquery.qrcode.min.js"></script>
    
    <script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
    
     @if(login_user.wxunionid==null || login_user.wxunionid==""){
            <a  style="margin-left: -1000px;cursor: pointer" id="wxBind">【绑定微信】</a>
            @}else{
            <a style="margin-left: -1000px">已绑定</a>
            @}
    
      <div style="position: absolute;margin-top: -40px;margin-left: 100px;background-color: #eee" id="login_container"></div>
    
    
    
    
     var obj = new WxLogin({
            self_redirect:false,
            id:"login_container",
            appid: "wx4e5373274d806988",
            scope: "snsapi_login",
            redirect_uri: "http%3a%2f%2fwww.3dmomoda.com/zone/ucenter",
            state: "STATE",
            style: "",
            href: ""
        });
    
         $("#wxBind").click(function () {
                $("#login_container").toggle();
        })
    1. 后台代码
    /**
         * 用户空间 个人资料
         */
        @Before(UserLoginInterceptor.class)
        public void ucenter() {
            String login_userid = CasKit.getStr("userid");
            this.setAttr("zone_navba", "ucenter");
            String code = this.getPara("code","");
            String state = this.getPara("state","");
    
            User user = User.dao.getById(login_userid);
            if (user != null) {
                if(!"".equals(code)){
                    String result = HttpClientUtil.getForObject("https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx4e5373274d806988&secret=8b4f2363f85adf43aeb41c5b729731b3&code=" + code + "&grant_type=authorization_code");
                    WxInfo wxInfo=JSON.parseObject(result, WxInfo.class);
                    String userInfo = HttpClientUtil.getForObject("https://api.weixin.qq.com/sns/userinfo?access_token="+wxInfo.getAccess_token()+"&openid="+wxInfo.getOpenid());
                    WxUserInfo wxUserInfo=JSON.parseObject(userInfo, WxUserInfo.class);
                    log.error(wxUserInfo.toString());
                    user.set("wxname",wxUserInfo.getNickname());
                    user.set("wximg",wxUserInfo.getHeadimgurl());
                    user.set("wxsex",wxUserInfo.getSex());
                    user.set("wxopenid",wxUserInfo.getOpenid());
                    user.set("wxunionid",wxUserInfo.getUnionid());
                    user.update();
                }
                this.setAttr("self", true);
                this.setAttr("his", "我");
                this.setAttr("user", user);
                if (this.getPara("_pjax") == null && this.getPara("_ajax") == null) {
                    this.render("/zone/ucenter/index.html");
                } else {
                    this.render("/zone/ucenter/item.html");
                }
            } else {
                throw new RuntimeException("用户不存在啊,请重新登录");
            }
        }
    

    6.完整代码

    1. 前台:
    <script type="text/javascript" src="${base}/theme2/plugins/jquery.qrcode.min.js"></script>
    <script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
    <div class="call-to-action">
        <div class="row">
            <div class="text-left user-info" style="width: 55%">
                <label>用户ID: </label> <span>${user.userid}</span>
            </div>
            <div class="text-left user-info" style="width: 55%;">
                <label>用户名: </label> <span>
                    @if(!strutil.contain(login_user.username, "@default.default")){
                        ${login_user.username}
                    @}
                </span>
            </div>
            <div class="text-left user-info" style="width: 55%;">
                <label>邮&nbsp;&nbsp;&nbsp;箱: </label> <span>
                    @if(!strutil.contain(login_user.email, "@default.default")){
                        ${login_user.email}
                    @}
                </span>
            </div>
            <div class="text-left user-info" style="width: 55%;">
                <label>微&nbsp;&nbsp;&nbsp;信: </label> <span>
                    @if(login_user.wxunionid==null || login_user.wxunionid==""){
    
                    @}else{
                        ${login_user.wxname}
                    @}
                </span>
            </div>
            @if(login_user.wxunionid==null || login_user.wxunionid==""){
            <a  style="margin-left: -1000px;cursor: pointer" id="wxBind">【绑定微信】</a>
            @}else{
            <a style="margin-left: -1000px">已绑定</a>
            @}
            <div style="position:relative">
                <div style="position: absolute;margin-top: -40px;margin-left: 100px;background-color: #eee" id="login_container"></div>
                <div class="text-left user-info">
                    <label>姓&nbsp;&nbsp;&nbsp;名:</label> <span>${login_user.name}</span>
                </div>
                <div class="text-left user-info">
                    <label>公&nbsp;&nbsp;&nbsp;司:</label> <span style="display: inline-block;width: 325px">${login_user.company}</span> <label>行&nbsp;&nbsp;&nbsp;业:</label> <span>${user.vocation}</span>
                </div>
                <div class="text-left user-info">
                    <label>地&nbsp;&nbsp;&nbsp;区: </label> <span>${login_user.provice}&nbsp;${user.city}</span>
                </div>
                <div class="text-left user-info">
                    <label>手机号: </label> <span>${login_user.phone}</span>
                </div>
                <div class="text-left user-info">
                    <label>QQ号&nbsp;: </label> <span>${login_user.qq}</span>
                </div>
            </div>
            <div style="width: 75%; margin-top: 66px;">
                <div class="btn btn-default btn-block" id="editUserInfoBtn" style="display:inline-block;width: 10%;">编辑资料
                </div>
            </div>
            <div class="info_img" style="width: 116px;height: 116px;display: inline-block;position: absolute;top:10px;right: 30%;">
                <img id="clickHeadimg" class="img-rounded" src="${has(headimg)?headimg:'/images/user/user-defalut.svg'}" onerror="imgError(this)" style="display:inline-block;width:100%;height:100%;border-radius: 50%;"/>
                <p style="font-size: 15px;font-weight: bold;color: #666666;margin-top: 10px;">头&nbsp;&nbsp;像</p>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            //进入编辑页面
            $("#editUserInfoBtn").on("click", function () {
                $.post('/zone/getEditInfoPage', '', function (data) {
                    $("#user-center-body").html(data);
                });
            });
    
            $("#login_container").hide();
        });
    
        var obj = new WxLogin({
            self_redirect:false,
            id:"login_container",
            appid: "wx4e5373274d806988",
            scope: "snsapi_login",
            redirect_uri: "http%3a%2f%2fwww.3dmomoda.com/zone/ucenter",
            state: "STATE",
            style: "",
            href: ""
        });
    
    
    </script>
    <script>
        $("#wxBind").click(function () {
                $("#login_container").toggle();
        })
    </script>
    1. 后台
    /**
         * 用户空间 个人资料
         */
        @Before(UserLoginInterceptor.class)
        public void ucenter() {
            String login_userid = CasKit.getStr("userid");
            this.setAttr("zone_navba", "ucenter");
            String code = this.getPara("code","");
            String state = this.getPara("state","");
    
            User user = User.dao.getById(login_userid);
            if (user != null) {
                if(!"".equals(code)){
                    String result = HttpClientUtil.getForObject("https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx4e5373274d806988&secret=8b4f2363f85adf43aeb41c5b729731b3&code=" + code + "&grant_type=authorization_code");
                    WxInfo wxInfo=JSON.parseObject(result, WxInfo.class);
                    String userInfo = HttpClientUtil.getForObject("https://api.weixin.qq.com/sns/userinfo?access_token="+wxInfo.getAccess_token()+"&openid="+wxInfo.getOpenid());
                    WxUserInfo wxUserInfo=JSON.parseObject(userInfo, WxUserInfo.class);
                    log.error(wxUserInfo.toString());
                    user.set("wxname",wxUserInfo.getNickname());
                    user.set("wximg",wxUserInfo.getHeadimgurl());
                    user.set("wxsex",wxUserInfo.getSex());
                    user.set("wxopenid",wxUserInfo.getOpenid());
                    user.set("wxunionid",wxUserInfo.getUnionid());
                    user.update();
                }
                this.setAttr("self", true);
                this.setAttr("his", "我");
                this.setAttr("user", user);
                if (this.getPara("_pjax") == null && this.getPara("_ajax") == null) {
                    this.render("/zone/ucenter/index.html");
                } else {
                    this.render("/zone/ucenter/item.html");
                }
            } else {
                throw new RuntimeException("用户不存在啊,请重新登录");
            }
        }

    3.工具类

    package com.momoda.util;
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.HttpMethodBase;
    import org.apache.commons.httpclient.NameValuePair;
    import org.apache.commons.httpclient.methods.GetMethod;
    import org.apache.commons.httpclient.methods.PostMethod;
    import org.apache.commons.httpclient.params.HttpMethodParams;
    import org.apache.commons.lang.text.StrBuilder;
    import org.apache.http.Consts;
    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.client.methods.CloseableHttpResponse;
    import org.apache.http.client.methods.HttpGet;
    import org.apache.http.impl.client.CloseableHttpClient;
    import org.apache.http.impl.client.HttpClients;
    
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public class HttpClientUtil {
    
        public static HttpClient httpClient = new HttpClient();
    
        /**
         * 字符串生成Map
         */
        public static <T> T createParamasMap(Object... strs) {
            if (strs.length % 2 != 0) {
                return null;
            }
    
            Map ret = new HashMap();
            for (int i = 0; i < strs.length; i++) {
                ret.put(strs[i], strs[i + 1]);
                i++;
            }
            return (T) ret;
        }
    
        /**
         * 创建表单PostMethod
         */
        public static PostMethod createPostMethod(String url, Map<String, String> params) {
            PostMethod postMethod = new PostMethod(url);
            postMethod.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8,en;q=0.6");
            postMethod.setRequestHeader("Referer", "http://www.3dmomoda.com");
            String agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36";
            postMethod.setRequestHeader("User-Agent", agent);
            if (params != null) {
                List<NameValuePair> paramsData = new ArrayList<NameValuePair>();
                for (String key : params.keySet()) {
                    paramsData.add(new NameValuePair(key, params.get(key)));
                }
                NameValuePair[] nvpArray = new NameValuePair[paramsData.size()];
                postMethod.setRequestBody(paramsData.toArray(nvpArray));
            }
            postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
            return postMethod;
        }
    
        /**
         * 创建get
         */
        public static GetMethod createGetMethod(String url) {
            GetMethod getMethod = new GetMethod(url);
            getMethod.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8,en;q=0.6");
            getMethod.setRequestHeader("Referer", "http://www.3dmomoda.com");
            String agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36";
            getMethod.setRequestHeader("User-Agent", agent);
            getMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
            return getMethod;
        }
    
        /**
         * 获取response返回的信息
         */
        public static String getResponseString(HttpMethodBase pm, String charset) {
            StringBuffer response = new StringBuffer();
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(pm.getResponseBodyAsStream(), charset));
                String line = "";
                int linecount = 0;
                while ((line = reader.readLine()) != null) {
                    if (linecount > 0 && line != null && !line.equals("")) {
                        response.append(System.getProperty("line.separator"));
                    }
                    response.append(line);
                    linecount++;
                }
                reader.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return response.toString();
        }
    
    
    
        public static String getForObject(String url) {
            CloseableHttpClient client=HttpClients.createDefault();
            HttpGet get=new HttpGet(url);
            try {
                CloseableHttpResponse response=client.execute(get);
                if(response.getStatusLine().getStatusCode()==200){
                    return getStringResult(response);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                try {
                    client.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
    
            return null;
        }
    
    
        public static String getStringResult(HttpResponse response){
            HttpEntity entity = response.getEntity();
            if(entity==null) return null;
    
            try {
                InputStream is = entity.getContent();
                //转换为字节输入流
                BufferedReader br = new BufferedReader(new InputStreamReader(is, Consts.UTF_8));
                StrBuilder builder = new StrBuilder();
                String body;
                while ((body = br.readLine()) != null) {
                    builder.append(body);
                }
    
                return builder.toString();
            } catch (IOException e) {
                e.printStackTrace();
            }
    
            return null;
        }
    
    }
    
    展开全文
  • java获取手机号归属地一般想获取手机号归属地等信息个人是无法获取的,但是可以通过调用第三方接口获取,具体百度搜索很多 这里例子提供一个淘宝的接口 ,该功能已经发布到网站作为一个在线小工具, 拿走不谢:...

    java获取手机号归属地一般想获取手机号归属地等信息个人是无法获取的,但是可以通过调用第三方接口获取,具体百度搜索很多
    这里例子提供一个淘宝的接口 ,该功能已经发布到网站作为一个在线小工具,
    拿走不谢:
    http://www.yzcopen.com/con/iphone
    用都的jar  httpClient相关
    代码:
        

        public class HttpTool {
    
        /**
         * 手机号地区接口
         * @param request
         * @return
         */
        private final static String iphoneurl = "http://mobsec-dianhua.baidu.com/dianhua_api/open/location?tel=";
    
        /**
         * http请求
         * @return
         * @throws Exception
         */
        public static String doHttpgetAPi(String url)  throws Exception {
            HttpGet post = null;
             CloseableHttpResponse response = null;
            try {
                CloseableHttpClient httpClient = HttpClients.createDefault();
                 post = new HttpGet(url);
                // 构造消息头
                 post.setHeader("Content-Type", "application/json; charset=utf-8");
                 post.setHeader("Connection", "Close");
                 response =  httpClient.execute(post);
                if(response != null){
                      HttpEntity entity=response.getEntity();  
                        String str=EntityUtils.toString(entity); 
                      return str;
                }
                return null;
            } catch (Exception e) {
                e.printStackTrace();
            }finally{
                if(response!=null){
                    response.getEntity().getContent().close();
                }
                if(post != null){
                    try {
                        post.releaseConnection();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            return null;
        }
        
        public static void main(String[] args) {
            String ipurl = iphoneurl+"您的手机号";
            String result = HttpTool.doHttpgetAPi(url);
            System.out.println(result );
        }
      }

    通过执行返回的结果是:
    {"response":{"13854510856":{"detail":{"area":[{"city":"烟台"}],"province":"山东","type":"domestic","operator":"移动"},"location":"山东烟台移动"}},"responseHeader":{"status":200,"time":1579079131507,"version":"1.1.0"}}

    展开全文
  • 创建小程序项目(测试即可) 创建Java后台项目(此处为SpringBoot 普通项目) 二、前端代码  WXML 代码 &lt;!--index.wxml--&gt; &lt;view class="container"&gt; &lt;view ...
  • <p><strong>那我这个授权手机号接口,到底是干什么?</strong><strong>完全不懂,有大佬解释一下吗?跪谢</strong></p>   <p><img alt="" height="773" src=...
  • 大量的手机号码按照记事本格式(记事本文档里面只可以有手机号和状态)导入(手机号----状态) //导出跳转 @GetMapping("/phone-list-export") public ModelAndView toexport(){ ModelAndView mv = ...
  • 21个目标文件 摘要:JAVA源码,媒体网络,山寨QQ,Java聊天程序 Java编写的山寨QQ,多人聊天+用户在线,程序分服务端和客户端,典型C/S结构, 当用户发送第一次请求的时候,验证用户登录,创建一个该qq和服务器端保持...
  • 具体思路为:小程序前端点击按钮,弹出授权手机号窗口,用户允许后,js得到加密数据,加密向量,session_key,将这些信息传递到java后台解密,最终拿到电话号码。(直接通过js是获取不到的) wxml按钮的代码为: ...
  • 配置文件 WxConstant.java /** * wx 配置文件 * */ public class WxConstant { public static final String appid = "你的appid"; public static final String secret = "你的secret"; public static final ...
  • java中验证国际手机号码

    千次阅读 2018-11-02 10:59:18
    最近有QA的同事反馈需要在后台验证手机号码的有效性,由于项目的国际化,所以用简单的正则很难实现,最后发现采用谷歌的libphonenumber可以很好地的很方便的实现。
  • 按照微信小程序官方文档,获取用户手机号分为2部分 微信小程序官网路径:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html 1.根据前端发送的code,根据微信提供的接口获取 ...
  • 基本流程就是 1、前端向微信获取code给个后端,后端根据code换取openid和sessionKey ...详情官网:微信小程序获取手机号 本人为后端攻城狮所以只能提供后端逻辑,废话少说直接上代码 1、后端拿到code、enc
  • package myst.yynz.shop.util; import ... import java.util.regex.Pattern; /** * @author cyh ... * @date 2021/4/9 13:58 ... //校验手机是否合规 2020年最全的国内手机号格式 private static fi
  • 微信小程序授权登录、绑定手机号含接口和小程序1、小程序授权登录1.1、小程序...本篇博客主要为了记录小程序授权登录和绑定手机号功能的实现,包含小程序端和API(java语言开发)。 1、小程序授权登录 1.1、小程序端 ...
  • 获取微信用户绑定手机号,需先调用wx.login接口。 因为需要用户主动触发才能发起获取手机号接口,所以该功能不由 API 来调用,需用button组件的点击来触发。 注意:目前该接口针对非个人开发者,且完成了认证的...
  • 小程序官方文档中介绍:获取微信用户绑定手机号,需先调用wx.login接口。因为需要用户主动触发才能发起获取手机号接口,所以该功能不由 API 来调用,需用 button 组件的点击来触发。注意:目前该接口针对非个人...
  • 创建小程序项目(测试即可) 创建Java后台项目(此处为SpringBoot 普通项目) 二、前端代码 WXML 代码 <!--index.wxml--> <view class="container"> <view class="userinfo"> <button wx:...
  • 微信小程序授权登录java代码微信小程序授权登录java代码 微信小程序授权登录java代码 微信小程序登录和普通后台系统登录不一样,因为这并不是你输入账户密码然后点击登录就登录了,而是通过微信授权,去换取openid,...
  • java 界面实现动态验证码

    万次阅读 2019-01-18 19:13:33
    一、生成验证码 (参考博文链接:https://www.cnblogs.com/nanyangke-cjz/p/7049281.html) ... import java.awt.Color; import java.awt.Font;...import java.awt.Graphics;...import java.awt.image.BufferedImag...
  • 刚做过的项目中,用到了,大家想看的,可以下载。
  • 2.微信后台监听用户扫码事件,从事件从获取场景值并解析出用户主键,取出用户并设置openid的值,就此绑定成功。 @RequestMapping(value = &amp;amp;amp;quot;/pInfoSubmit&amp;amp;amp;quot;, method = ...
  • LZ-Says:有些东西,真的是很矛盾,本来很简单的事儿,各自坚持,结果,不欢而散,不舍?...今天接到要实现一个解密微信小程序获取微信绑定手机号接口,有点懵。 下面一起开始吧~ 解密获取绑定...
  • googleAPI 验证手机号码C#代码版,验证手机号码,验证电话号码,传真,国外手机号码,国外电话号码,支持全球大部分国家电话号码的正确验证
  • 2.小程序授权获取手机号标签拿到encryptedData与iv # 授权按钮,绑定用户点击后的方法 getPhoneNumber() <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"></button> js方法: ...
  • private final static String message="手机电话簿"; public About(String title){ super(title); setTimeout(FOREVER); try { icon=Image.createImage("/icon/3.png"); setImage(icon); } catch ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 22,730
精华内容 9,092
关键字:

java绑定手机号

java 订阅