Skip to content

Commit 06d45dc

Browse files
authored
🎨 binarywang#1924 【企业微信】第三方应用suite_ticket改为默认30分钟失效
1 parent 0306103 commit 06d45dc

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,11 @@ public interface WxCpTpService {
7070
* 详情请见:https://work.weixin.qq.com/api/doc#90001/90143/90628
7171
* </pre>
7272
*
73-
* @Deprecated 由于无法主动刷新,所以这个接口实际已经没有意义,需要在接收企业微信的主动推送后,保存这个ticket
74-
* @see #setSuiteTicket(String)
75-
*
7673
* @param forceRefresh 强制刷新
7774
* @return the suite ticket
7875
* @throws WxErrorException the wx error exception
76+
* @Deprecated 由于无法主动刷新,所以这个接口实际已经没有意义,需要在接收企业微信的主动推送后,保存这个ticket
77+
* @see #setSuiteTicket(String)
7978
*/
8079
@Deprecated
8180
String getSuiteTicket(boolean forceRefresh) throws WxErrorException;
@@ -84,12 +83,28 @@ public interface WxCpTpService {
8483
* <pre>
8584
* 保存企业微信定时推送的suite_ticket,(每10分钟)
8685
* 详情请见:https://work.weixin.qq.com/api/doc#90001/90143/90628
86+
*
87+
* 注意:微信不是固定10分钟推送suite_ticket的, 且suite_ticket的有效期为30分钟
88+
* https://work.weixin.qq.com/api/doc/10975#%E8%8E%B7%E5%8F%96%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E5%87%AD%E8%AF%81
89+
* </pre>
90+
*
91+
* @param suiteTicket
92+
*/
93+
void setSuiteTicket(String suiteTicket);
94+
95+
/**
96+
* <pre>
97+
* 保存企业微信定时推送的suite_ticket,(每10分钟)
98+
* 详情请见:https://work.weixin.qq.com/api/doc#90001/90143/90628
99+
*
100+
* 注意:微信不是固定10分钟推送suite_ticket的, 且suite_ticket的有效期为30分钟
101+
* https://work.weixin.qq.com/api/doc/10975#%E8%8E%B7%E5%8F%96%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%94%E7%94%A8%E5%87%AD%E8%AF%81
87102
* </pre>
88103
*
89104
* @param suiteTicket
90-
* @throws WxErrorException
105+
* @param expiresInSeconds
91106
*/
92-
void setSuiteTicket(String suiteTicket) throws WxErrorException;
107+
void setSuiteTicket(String suiteTicket, int expiresInSeconds);
93108

94109
/**
95110
* 获取应用的 jsapi ticket
@@ -251,8 +266,8 @@ public interface WxCpTpService {
251266
/**
252267
* 获取WxMpConfigStorage 对象.
253268
*
254-
* @Deprecated storage应该在service内部使用,提供这个接口,容易破坏这个封装
255269
* @return WxMpConfigStorage wx cp tp config storage
270+
* @Deprecated storage应该在service内部使用,提供这个接口,容易破坏这个封装
256271
*/
257272
@Deprecated
258273
WxCpTpConfigStorage getWxCpTpConfigStorage();

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,14 @@ public String getSuiteTicket(boolean forceRefresh) throws WxErrorException {
104104
}
105105

106106
@Override
107-
public void setSuiteTicket(String suiteTicket) throws WxErrorException {
107+
public void setSuiteTicket(String suiteTicket){
108+
setSuiteTicket(suiteTicket, 28 * 60);
109+
}
110+
111+
@Override
112+
public void setSuiteTicket(String suiteTicket, int expiresInSeconds){
108113
synchronized (globalSuiteTicketRefreshLock) {
109-
this.configStorage.updateSuiteTicket(suiteTicket, 10 * 60);
114+
this.configStorage.updateSuiteTicket(suiteTicket, expiresInSeconds);
110115
}
111116
}
112117

0 commit comments

Comments
 (0)