File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -511,6 +511,17 @@ public interface WxMpService {
511
511
*/
512
512
public File qrCodePicture (WxMpQrCodeTicket ticket ) throws WxErrorException ;
513
513
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 ;
514
525
/**
515
526
* <pre>
516
527
* 换取二维码图片url地址
Original file line number Diff line number Diff line change @@ -519,17 +519,27 @@ public File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException {
519
519
}
520
520
521
521
@ Override
522
- public String qrCodePictureUrl (String ticket ) throws WxErrorException {
522
+ public String qrCodePictureUrl (String ticket , boolean needShortUrl ) throws WxErrorException {
523
523
String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s" ;
524
524
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 ;
527
532
} catch (UnsupportedEncodingException e ) {
528
533
WxError error = WxError .newBuilder ().setErrorCode (-1 )
529
534
.setErrorMsg (e .getMessage ()).build ();
530
535
throw new WxErrorException (error );
531
536
}
532
537
}
538
+
539
+ @ Override
540
+ public String qrCodePictureUrl (String ticket ) throws WxErrorException {
541
+ return qrCodePictureUrl (ticket , false );
542
+ }
533
543
534
544
@ Override
535
545
public String shortUrl (String long_url ) throws WxErrorException {
You can’t perform that action at this time.
0 commit comments