首页 > 代码库 > 微信获取二维码

微信获取二维码

微信获取二维码

String listUrl = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token="+accessToken;
        // {"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "123"}}}
        Map<String, Object> request = new HashMap<String, Object>();
        request.put("action_name", "QR_LIMIT_STR_SCENE");
        Map<String, Object> actionInfoMap = new HashMap<String, Object>();
        Map<String, String> sceneMap = new HashMap<String, String>();
        sceneMap.put("scene_str", qrid);
        actionInfoMap.put("scene", sceneMap);
        request.put("action_info", actionInfoMap);
        @SuppressWarnings("unchecked")
        Map<String,String> postMap = template.postForObject(listUrl, request, Map.class);
        if(postMap == null){
            return "";
        }
        String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=";
        return url + postMap.get("ticket");

 

微信获取二维码