Browse Source

替换hard code

master
BinaryWang 8 years ago
parent
commit
2ec3c527c2
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java

+ 4
- 1
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java View File

@@ -27,6 +27,8 @@ import me.chanjar.weixin.mp.bean.*;
import me.chanjar.weixin.mp.bean.result.*; import me.chanjar.weixin.mp.bean.result.*;
import me.chanjar.weixin.mp.util.http.*; import me.chanjar.weixin.mp.util.http.*;
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;

import org.apache.commons.io.Charsets;
import org.apache.http.Consts; import org.apache.http.Consts;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ClientProtocolException;
@@ -48,6 +50,7 @@ import java.io.InputStream;
import java.io.StringReader; import java.io.StringReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -478,7 +481,7 @@ public class WxMpServiceImpl implements WxMpService {
public String qrCodePictureUrl(String ticket) throws WxErrorException { public String qrCodePictureUrl(String ticket) throws WxErrorException {
String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s"; String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s";
try { try {
return String.format(url, URLEncoder.encode(ticket, "utf-8"));
return String.format(url, URLEncoder.encode(ticket, Charsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
WxError error = new WxError(); WxError error = new WxError();
error.setErrorCode(-1); error.setErrorCode(-1);


Loading…
Cancel
Save