1. 程式人生 > >微信小程式java生成二維碼-帶引數

微信小程式java生成二維碼-帶引數

/**
* 生成小程式二維碼 -並儲存到本地-返回二維碼地址

* @param request
* @param access_token
* @param path
* @param width
* @param scene
* @return
*/
public static String createwxaqrcode(HttpServletRequest request, String access_token, String path, String width,
String scene) {
String URL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + access_token;
// 二維碼圖片位置
String downloadUrl = null;
try {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, String> line_color = new HashMap<String, String>();
line_color.put("r", "0");
line_color.put("g", "0");
line_color.put("b", "0");
map.put("path", path);
map.put("width", width);
map.put("scene", scene);
map.put("auto_color", false);
map.put("line_color", line_color);
JSONObject json = JSONObject.fromObject(map);
downloadUrl = HttpClientConnectionManager.httpPostWithJSON(request, URL, json.toString(), scene);
// 返回給前端的後臺伺服器檔案下載路徑


} catch (Exception e) {
e.printStackTrace();
}
return downloadUrl;

}