|
|
@@ -0,0 +1,55 @@
|
|
|
+package com.mrxu.framework.common.weixin.api;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.mrxu.framework.common.weixin.base.WxHttp;
|
|
|
+import com.mrxu.framework.common.weixin.bean.Qrcode;
|
|
|
+
|
|
|
+public class WxQrcodeApi {
|
|
|
+
|
|
|
+ private static String codeUrl = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=";
|
|
|
+
|
|
|
+ private static String qrcodeUrl = "https://api.weixin.qq.com/cgi-bin/qrcode/create";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 产生临时二维码
|
|
|
+ * @param token
|
|
|
+ * @param expireSeconds 该二维码有效时间,以秒为单位。 最大不超过604800(即7天)
|
|
|
+ * @param value 32位非0整型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Qrcode getTempQrcode(String token,int expireSeconds, String value) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("expire_seconds", expireSeconds);
|
|
|
+ json.put("action_name", "QR_STR_SCENE");
|
|
|
+ //json.put("action_info", "{\"scene\":{\"scene_id\":"+value+"}}");
|
|
|
+
|
|
|
+ JSONObject actionInfo = new JSONObject();
|
|
|
+ JSONObject scene = new JSONObject();
|
|
|
+ scene.put("scene_str", value);
|
|
|
+ actionInfo.put("scene", scene);
|
|
|
+ json.put("action_info", actionInfo);
|
|
|
+ return WxHttp.post(Qrcode.class, qrcodeUrl+"?access_token="+token, json);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 产生永久二维码
|
|
|
+ * @param token
|
|
|
+ * @param value 32位非0整型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Qrcode getForeverQrcode(String token,String value) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("action_name", "QR_LIMIT_STR_SCENE");
|
|
|
+
|
|
|
+ JSONObject actionInfo = new JSONObject();
|
|
|
+ JSONObject scene = new JSONObject();
|
|
|
+ scene.put("scene_str", value);
|
|
|
+ actionInfo.put("scene", scene);
|
|
|
+ json.put("action_info", actionInfo);
|
|
|
+
|
|
|
+ return WxHttp.post(Qrcode.class, qrcodeUrl+"?access_token="+token, json);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|