Skip to content

Commit 0714cbe

Browse files
committed
binarywang#395 修复获取小程序二维码data format error的问题
1 parent 7b64b6b commit 0714cbe

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/AbstractWxMaQrcodeWrapper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
* @author Element
99
*/
1010
public abstract class AbstractWxMaQrcodeWrapper {
11+
public String toJson() {
12+
return WxMaGsonBuilder.create().toJson(this);
13+
}
1114

1215
@Override
1316
public String toString() {
14-
return WxMaGsonBuilder.create().toJson(this);
17+
return this.toJson();
1518
}
16-
1719
}

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/util/http/QrCodeRequestExecutor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ public File execute(String uri, AbstractWxMaQrcodeWrapper ticket) throws WxError
3737
HttpPost httpPost = new HttpPost(uri);
3838
if (requestHttp.getRequestHttpProxy() != null) {
3939
httpPost.setConfig(
40-
RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build()
40+
RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build()
4141
);
4242
}
43-
httpPost.setEntity(new StringEntity(ticket.toString()));
43+
httpPost.setEntity(new StringEntity(ticket.toJson()));
4444

4545
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpPost);
4646
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response);) {
4747
Header[] contentTypeHeader = response.getHeaders("Content-Type");
4848
if (contentTypeHeader != null && contentTypeHeader.length > 0
49-
&& ContentType.APPLICATION_JSON.getMimeType()
50-
.equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) {
49+
&& ContentType.APPLICATION_JSON.getMimeType()
50+
.equals(ContentType.parse(contentTypeHeader[0].getValue()).getMimeType())) {
5151
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
5252
throw new WxErrorException(WxError.fromJson(responseContent));
5353
}

0 commit comments

Comments
 (0)