mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	增加 换取二维码图片url地址的方法
This commit is contained in:
		| @ -508,6 +508,17 @@ public interface WxMpService { | ||||
|    */ | ||||
|   public File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 换取二维码图片url地址 | ||||
|    * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=生成带参数的二维码 | ||||
|    * </pre> | ||||
|    * @param ticket    二维码ticket | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    */ | ||||
|   public String qrCodePictureUrl(String ticket) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 长链接转短链接接口 | ||||
|  | ||||
| @ -46,6 +46,8 @@ import java.io.File; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
| import java.io.StringReader; | ||||
| import java.io.UnsupportedEncodingException; | ||||
| import java.net.URLEncoder; | ||||
| import java.security.NoSuchAlgorithmException; | ||||
| import java.util.*; | ||||
| import java.util.Map.Entry; | ||||
| @ -472,6 +474,19 @@ public class WxMpServiceImpl implements WxMpService { | ||||
|     return execute(new QrCodeRequestExecutor(), url, ticket); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public String qrCodePictureUrl(String ticket) throws WxErrorException { | ||||
|     String url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s"; | ||||
|     try { | ||||
|       return String.format(url, URLEncoder.encode(ticket, "utf-8")); | ||||
|     } catch (UnsupportedEncodingException e) { | ||||
|       WxError error = new WxError(); | ||||
|       error.setErrorCode(-1); | ||||
|       error.setErrorMsg(e.getMessage()); | ||||
|       throw new WxErrorException(error); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   public String shortUrl(String long_url) throws WxErrorException { | ||||
|     String url = "https://api.weixin.qq.com/cgi-bin/shorturl"; | ||||
|     JsonObject o = new JsonObject(); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 BinaryWang
					BinaryWang