| | |
| | | //生成小程序二维码地址(方形) |
| | | public static final String MAKE_TWOCODE_SQUARE_URL = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token="; |
| | | //生成小程序二维码地址(圆形) |
| | | public static final String MAKE_TWOCODE_ROUND_URL = "https://api.weixin.qq.com/wxa/getwxacode?access_token="; |
| | | public static final String MAKE_TWOCODE_ROUND_URL = "https://api.weixin.qq.com/wxa/getwxacode?access_token={0}"; |
| | | //生成无限二维码 |
| | | public static final String URL_UNLIMIT_SQUARE = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={0}"; |
| | | ////////////////////////////////////////////////// |
| | |
| | | * @return |
| | | */ |
| | | public static File createLimitedQrCode(String at, String page, int width, boolean autoColor, |
| | | JSONObject lineColor, boolean isHyaline) throws IOException { |
| | | JSONObject lineColor, boolean isHyaline) { |
| | | String imgUrl = null; |
| | | InputStream in = null; |
| | | HttpURLConnection conn = null; |
| | | |
| | | //创建临时文件 |
| | | File file = File.createTempFile("temp", ".jpg"); |
| | | |
| | | File file = null; |
| | | try { |
| | | file = File.createTempFile("temp", ".jpg"); |
| | | //生成发送数据 |
| | | JSONObject obj = new JSONObject(); |
| | | obj.put("width", width); |
| | | obj.put("page", page); |
| | | obj.put("path", page); |
| | | obj.put("auto_color", autoColor); |
| | | obj.put("line_color", lineColor); |
| | | obj.put("is_hyaline", isHyaline); |
| | |
| | | conn = null; |
| | | } |
| | | }finally { |
| | | file.deleteOnExit(); |
| | | if(file != null){ |
| | | file.deleteOnExit(); |
| | | } |
| | | } |
| | | return file; |
| | | } |