首先是获取AccessToken,上一篇有获取方法,网上其他的也OK。
// 获取 小程序二维码
@SuppressWarnings("unchecked")
public static String getWXShare(String scene,String page,String RFID,HttpServletRequest request) throws Exception {
//保存路径,示例
String uploadpath = ConfigUtil.get_instances().getuploadpath();/upload/imgs
//全路径(带域名),https://sss.ss-ss.cn/upload/imgs/ 本地写localhost.....
String path = request.getServletContext().getRealPath(uploadpath);
try {
String accessToken = getAccessToken();//获取的AccessToken
String redUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessToken;
JSONObject json = new JSONObject();
json.put("scene", scene); //需要携带的参数,不需要可以不写.
//page 是扫码进去的路径,默认 page/index/index 。主页面的话,可不写
String newFileName = DateUtil.formatDate(new Date(), "yyyyMM