File tree Expand file tree Collapse file tree
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -511,6 +511,17 @@ public interface WxMpService {
511511 */
512512 public File qrCodePicture (WxMpQrCodeTicket ticket ) throws WxErrorException ;
513513
514+ /**
515+ * <pre>
516+ * 换取二维码图片url地址(可以选择是否生成压缩的网址)
517+ * 详情请见: <a href="http://mp.weixin.qq.com/wiki/18/167e7d94df85d8389df6c94a7a8f78ba.html">生成带参数的二维码</a>
518+ * </pre>
519+ * @param ticket 二维码ticket
520+ * @param needShortUrl 是否需要压缩的二维码地址
521+ * @return
522+ * @throws WxErrorException
523+ */
524+ public String qrCodePictureUrl (String ticket , boolean needShortUrl ) throws WxErrorException ;
514525 /**
515526 * <pre>
516527 * 换取二维码图片url地址
Original file line number Diff line number Diff line change @@ -519,17 +519,27 @@ public File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException {
519519 }
520520
521521 @ Override
522- public String qrCodePictureUrl (String ticket ) throws WxErrorException {
522+ public String qrCodePictureUrl (String ticket , boolean needShortUrl ) throws WxErrorException {
523523 String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s" ;
524524 try {
525- return this .shortUrl (String .format (url ,
526- URLEncoder .encode (ticket , Charsets .UTF_8 .name ())));
525+ String resultUrl = String .format (url ,
526+ URLEncoder .encode (ticket , Charsets .UTF_8 .name ()));
527+ if (needShortUrl ){
528+ return this .shortUrl (resultUrl );
529+ }
530+
531+ return resultUrl ;
527532 } catch (UnsupportedEncodingException e ) {
528533 WxError error = WxError .newBuilder ().setErrorCode (-1 )
529534 .setErrorMsg (e .getMessage ()).build ();
530535 throw new WxErrorException (error );
531536 }
532537 }
538+
539+ @ Override
540+ public String qrCodePictureUrl (String ticket ) throws WxErrorException {
541+ return qrCodePictureUrl (ticket , false );
542+ }
533543
534544 @ Override
535545 public String shortUrl (String long_url ) throws WxErrorException {
You can’t perform that action at this time.
0 commit comments