File tree Expand file tree Collapse file tree
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 * <pre>
88 * 小程序Scheme码相关操作接口.
99 *
10- * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-scheme/urlscheme.generate.html
10+ *
1111 * </pre>
1212 *
1313 * @author : cofedream
1616public interface WxMaSchemeService {
1717 /**
1818 * 获取小程序scheme码
19- *
19+ *文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-scheme/urlscheme.generate.html
2020 * @param request 请求参数
2121 * @throws WxErrorException 生成失败时抛出,具体错误码请看文档
2222 */
2323 String generate (WxMaGenerateSchemeRequest request ) throws WxErrorException ;
24+ /**
25+ * 获取NFC 的小程序 scheme
26+ *文档地址:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/url-scheme/generateNFCScheme.html
27+ * @param request 请求参数
28+ * @throws WxErrorException 生成失败时抛出,具体错误码请看文档
29+ */
30+ String generateNFC (WxMaGenerateSchemeRequest request ) throws WxErrorException ;
2431}
Original file line number Diff line number Diff line change 1111import me .chanjar .weixin .common .error .WxErrorException ;
1212import me .chanjar .weixin .common .util .json .GsonParser ;
1313
14+ import static cn .binarywang .wx .miniapp .constant .WxMaApiUrlConstants .Scheme .GENERATE_NFC_SCHEME_URL ;
1415import static cn .binarywang .wx .miniapp .constant .WxMaApiUrlConstants .Scheme .GENERATE_SCHEME_URL ;
1516
1617/**
2122public class WxMaSchemeServiceImpl implements WxMaSchemeService {
2223 private final WxMaService wxMaService ;
2324
25+ /**
26+ * 获取小程序scheme码
27+ * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-scheme/urlscheme.generate.html
28+ *
29+ * @param request 请求参数
30+ * @throws WxErrorException 生成失败时抛出,具体错误码请看文档
31+ */
2432 @ Override
2533 public String generate (WxMaGenerateSchemeRequest request ) throws WxErrorException {
2634 String responseContent = this .wxMaService .post (GENERATE_SCHEME_URL , request .toJson ());
@@ -30,4 +38,21 @@ public String generate(WxMaGenerateSchemeRequest request) throws WxErrorExceptio
3038 }
3139 return jsonObject .get ("openlink" ).getAsString ();
3240 }
41+
42+ /**
43+ * 获取NFC 的小程序 scheme
44+ * 文档地址:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/url-scheme/generateNFCScheme.html
45+ *
46+ * @param request 请求参数
47+ * @throws WxErrorException 生成失败时抛出,具体错误码请看文档
48+ */
49+ @ Override
50+ public String generateNFC (WxMaGenerateSchemeRequest request ) throws WxErrorException {
51+ String responseContent = this .wxMaService .post (GENERATE_NFC_SCHEME_URL , request .toJson ());
52+ JsonObject jsonObject = GsonParser .parse (responseContent );
53+ if (jsonObject .get (WxConsts .ERR_CODE ).getAsInt () != 0 ) {
54+ throw new WxErrorException (WxError .fromJson (responseContent , WxType .MiniApp ));
55+ }
56+ return jsonObject .get ("openlink" ).getAsString ();
57+ }
3358}
Original file line number Diff line number Diff line change @@ -339,6 +339,7 @@ public interface Run {
339339
340340 public interface Scheme {
341341 String GENERATE_SCHEME_URL = "https://api.weixin.qq.com/wxa/generatescheme" ;
342+ String GENERATE_NFC_SCHEME_URL = "https://api.weixin.qq.com/wxa/generatenfcscheme" ;
342343 }
343344
344345 public interface Link {
You can’t perform that action at this time.
0 commit comments