Skip to content

Commit ec2e599

Browse files
committed
修复两个客服接口地址问题(怀疑是微信官方偷偷改了的??!!!)
1 parent 26af3c5 commit ec2e599

File tree

1 file changed

+11
-45
lines changed

1 file changed

+11
-45
lines changed

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
package me.chanjar.weixin.mp.api.impl;
22

3-
import java.io.File;
4-
import java.util.Date;
5-
6-
import org.slf4j.Logger;
7-
import org.slf4j.LoggerFactory;
8-
93
import com.google.gson.JsonObject;
10-
114
import me.chanjar.weixin.common.bean.result.WxError;
125
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
136
import me.chanjar.weixin.common.exception.WxErrorException;
@@ -17,22 +10,23 @@
1710
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
1811
import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfAccountRequest;
1912
import me.chanjar.weixin.mp.bean.kefu.request.WxMpKfSessionRequest;
20-
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfList;
21-
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfMsgList;
22-
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfOnlineList;
23-
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionGetResult;
24-
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionList;
25-
import me.chanjar.weixin.mp.bean.kefu.result.WxMpKfSessionWaitCaseList;
13+
import me.chanjar.weixin.mp.bean.kefu.result.*;
14+
import org.slf4j.Logger;
15+
import org.slf4j.LoggerFactory;
16+
17+
import java.io.File;
18+
import java.util.Date;
2619

2720
/**
28-
*
21+
*
2922
* @author Binary Wang
3023
*
3124
*/
3225
public class WxMpKefuServiceImpl implements WxMpKefuService {
3326
protected final Logger log = LoggerFactory
3427
.getLogger(WxMpKefuServiceImpl.class);
3528
private static final String API_URL_PREFIX = "https://api.weixin.qq.com/customservice";
29+
private static final String API_URL_PREFIX_WITH_CGI_BIN = "https://api.weixin.qq.com/cgi-bin/customservice";
3630
private WxMpService wxMpService;
3731

3832
public WxMpKefuServiceImpl(WxMpService wxMpService) {
@@ -44,26 +38,20 @@ public boolean customMessageSend(WxMpCustomMessage message)
4438
throws WxErrorException {
4539
String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send";
4640
String responseContent = this.wxMpService.post(url, message.toJson());
47-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, message.toJson(),
48-
responseContent);
4941
return true;
5042
}
5143

5244
@Override
5345
public WxMpKfList kfList() throws WxErrorException {
54-
String url = API_URL_PREFIX + "/getkflist";
46+
String url = API_URL_PREFIX_WITH_CGI_BIN + "/getkflist";
5547
String responseContent = this.wxMpService.get(url, null);
56-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null,
57-
responseContent);
5848
return WxMpKfList.fromJson(responseContent);
5949
}
6050

6151
@Override
6252
public WxMpKfOnlineList kfOnlineList() throws WxErrorException {
63-
String url = API_URL_PREFIX + "/getonlinekflist";
53+
String url = API_URL_PREFIX_WITH_CGI_BIN + "/getonlinekflist";
6454
String responseContent = this.wxMpService.get(url, null);
65-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null,
66-
responseContent);
6755
return WxMpKfOnlineList.fromJson(responseContent);
6856
}
6957

@@ -72,8 +60,6 @@ public boolean kfAccountAdd(WxMpKfAccountRequest request)
7260
throws WxErrorException {
7361
String url = API_URL_PREFIX + "/kfaccount/add";
7462
String responseContent = this.wxMpService.post(url, request.toJson());
75-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(),
76-
responseContent);
7763
return true;
7864
}
7965

@@ -82,17 +68,13 @@ public boolean kfAccountUpdate(WxMpKfAccountRequest request)
8268
throws WxErrorException {
8369
String url = API_URL_PREFIX + "/kfaccount/update";
8470
String responseContent = this.wxMpService.post(url, request.toJson());
85-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(),
86-
responseContent);
8771
return true;
8872
}
8973

9074
@Override
9175
public boolean kfAccountInviteWorker(WxMpKfAccountRequest request) throws WxErrorException {
9276
String url = API_URL_PREFIX + "/kfaccount/inviteworker";
9377
String responseContent = this.wxMpService.post(url, request.toJson());
94-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(),
95-
responseContent);
9678
return true;
9779
}
9880

@@ -102,18 +84,13 @@ public boolean kfAccountUploadHeadImg(String kfAccount, File imgFile)
10284
String url = API_URL_PREFIX + "/kfaccount/uploadheadimg?kf_account=" + kfAccount;
10385
WxMediaUploadResult responseContent = this.wxMpService
10486
.execute(new MediaUploadRequestExecutor(), url, imgFile);
105-
this.log.debug("\nurl:{}\nparams:{}&file:{}\nresponse:{}", url, kfAccount,
106-
imgFile.getAbsolutePath(),
107-
responseContent);
10887
return true;
10988
}
11089

11190
@Override
11291
public boolean kfAccountDel(String kfAccount) throws WxErrorException {
11392
String url = API_URL_PREFIX + "/kfaccount/del?kf_account=" + kfAccount;
11493
String responseContent = this.wxMpService.get(url, null);
115-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null,
116-
responseContent);
11794
return true;
11895
}
11996

@@ -123,8 +100,6 @@ public boolean kfSessionCreate(String openid, String kfAccount)
123100
WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid);
124101
String url = API_URL_PREFIX + "/kfsession/create";
125102
String responseContent = this.wxMpService.post(url, request.toJson());
126-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(),
127-
responseContent);
128103
return true;
129104
}
130105

@@ -134,8 +109,6 @@ public boolean kfSessionClose(String openid, String kfAccount)
134109
WxMpKfSessionRequest request = new WxMpKfSessionRequest(kfAccount, openid);
135110
String url = API_URL_PREFIX + "/kfsession/close";
136111
String responseContent = this.wxMpService.post(url, request.toJson());
137-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, request.toJson(),
138-
responseContent);
139112
return true;
140113
}
141114

@@ -144,8 +117,6 @@ public WxMpKfSessionGetResult kfSessionGet(String openid)
144117
throws WxErrorException {
145118
String url = API_URL_PREFIX + "/kfsession/getsession?openid=" + openid;
146119
String responseContent = this.wxMpService.get(url, null);
147-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null,
148-
responseContent);
149120
return WxMpKfSessionGetResult.fromJson(responseContent);
150121
}
151122

@@ -154,8 +125,6 @@ public WxMpKfSessionList kfSessionList(String kfAccount)
154125
throws WxErrorException {
155126
String url = API_URL_PREFIX + "/kfsession/getsessionlist?kf_account=" + kfAccount;
156127
String responseContent = this.wxMpService.get(url, null);
157-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null,
158-
responseContent);
159128
return WxMpKfSessionList.fromJson(responseContent);
160129
}
161130

@@ -164,8 +133,6 @@ public WxMpKfSessionWaitCaseList kfSessionGetWaitCase()
164133
throws WxErrorException {
165134
String url = API_URL_PREFIX + "/kfsession/getwaitcase";
166135
String responseContent = this.wxMpService.get(url, null);
167-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, null,
168-
responseContent);
169136
return WxMpKfSessionWaitCaseList.fromJson(responseContent);
170137
}
171138

@@ -188,8 +155,7 @@ public WxMpKfMsgList kfMsgList(Date startTime, Date endTime, Long msgId, Integer
188155
param.addProperty("number", number); //number 每次获取条数,最多10000条
189156

190157
String responseContent = this.wxMpService.post(url, param.toString());
191-
this.log.debug("\nurl:{}\nparams:{}\nresponse:{}", url, param.toString(),
192-
responseContent);
158+
193159
return WxMpKfMsgList.fromJson(responseContent);
194160
}
195161

0 commit comments

Comments
 (0)