mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-24 13:03:46 +08:00
issue #5 生成带参数的二维码 - ticket
This commit is contained in:
@@ -31,6 +31,7 @@ import chanjarster.weixin.bean.result.WxError;
|
||||
import chanjarster.weixin.bean.result.WxMassSendResult;
|
||||
import chanjarster.weixin.bean.result.WxMassUploadResult;
|
||||
import chanjarster.weixin.bean.result.WxMediaUploadResult;
|
||||
import chanjarster.weixin.bean.result.WxQrCodeTicket;
|
||||
import chanjarster.weixin.bean.result.WxUser;
|
||||
import chanjarster.weixin.bean.result.WxUserList;
|
||||
import chanjarster.weixin.exception.WxErrorException;
|
||||
@@ -263,6 +264,35 @@ public class WxServiceImpl implements WxService {
|
||||
return WxUserList.fromJson(responseContent);
|
||||
}
|
||||
|
||||
public WxQrCodeTicket qrCodeCreateTmpTicket(int scene_id, Integer expire_seconds) throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create";
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("action_name", "QR_SCENE");
|
||||
if(expire_seconds != null) {
|
||||
json.addProperty("expire_seconds", expire_seconds);
|
||||
}
|
||||
JsonObject actionInfo = new JsonObject();
|
||||
JsonObject scene = new JsonObject();
|
||||
scene.addProperty("scene_id", scene_id);
|
||||
actionInfo.add("scene", scene);
|
||||
json.add("action_info", actionInfo);
|
||||
String responseContent = execute(new SimplePostRequestExecutor(), url, json.toString());
|
||||
return WxQrCodeTicket.fromJson(responseContent);
|
||||
}
|
||||
|
||||
public WxQrCodeTicket qrCodeCreateLastTicket(int scene_id) throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/qrcode/create";
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("action_name", "QR_LIMIT_SCENE");
|
||||
JsonObject actionInfo = new JsonObject();
|
||||
JsonObject scene = new JsonObject();
|
||||
scene.addProperty("scene_id", scene_id);
|
||||
actionInfo.add("scene", scene);
|
||||
json.add("action_info", actionInfo);
|
||||
String responseContent = execute(new SimplePostRequestExecutor(), url, json.toString());
|
||||
return WxQrCodeTicket.fromJson(responseContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求
|
||||
* @param executor
|
||||
|
Reference in New Issue
Block a user