File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -508,6 +508,17 @@ public interface WxMpService {
508
508
*/
509
509
public File qrCodePicture (WxMpQrCodeTicket ticket ) throws WxErrorException ;
510
510
511
+ /**
512
+ * <pre>
513
+ * 换取二维码图片url地址
514
+ * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=生成带参数的二维码
515
+ * </pre>
516
+ * @param ticket 二维码ticket
517
+ * @return
518
+ * @throws WxErrorException
519
+ */
520
+ public String qrCodePictureUrl (String ticket ) throws WxErrorException ;
521
+
511
522
/**
512
523
* <pre>
513
524
* 长链接转短链接接口
Original file line number Diff line number Diff line change 46
46
import java .io .IOException ;
47
47
import java .io .InputStream ;
48
48
import java .io .StringReader ;
49
+ import java .io .UnsupportedEncodingException ;
50
+ import java .net .URLEncoder ;
49
51
import java .security .NoSuchAlgorithmException ;
50
52
import java .util .*;
51
53
import java .util .Map .Entry ;
@@ -472,6 +474,19 @@ public File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException {
472
474
return execute (new QrCodeRequestExecutor (), url , ticket );
473
475
}
474
476
477
+ @ Override
478
+ public String qrCodePictureUrl (String ticket ) throws WxErrorException {
479
+ String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s" ;
480
+ try {
481
+ return String .format (url , URLEncoder .encode (ticket , "utf-8" ));
482
+ } catch (UnsupportedEncodingException e ) {
483
+ WxError error = new WxError ();
484
+ error .setErrorCode (-1 );
485
+ error .setErrorMsg (e .getMessage ());
486
+ throw new WxErrorException (error );
487
+ }
488
+ }
489
+
475
490
public String shortUrl (String long_url ) throws WxErrorException {
476
491
String url = "https://api.weixin.qq.com/cgi-bin/shorturl" ;
477
492
JsonObject o = new JsonObject ();
You can’t perform that action at this time.
0 commit comments