Skip to content

Commit bb6bec0

Browse files
authored
🆕 #2379 【微信开放平台】增加个人小程序快速注册和试用小程序快速注册相关接口
1 parent 88301a6 commit bb6bec0

5 files changed

Lines changed: 120 additions & 0 deletions

File tree

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ public interface WxOpenComponentService {
120120
*/
121121
String FAST_REGISTER_WEAPP_SEARCH_URL = "https://api.weixin.qq.com/cgi-bin/component/fastregisterweapp?action=search";
122122

123+
/**
124+
* 快速创建个人小程序接口.
125+
*/
126+
String FAST_REGISTER_PERSONAL_WEAPP_URL = "https://api.weixin.qq.com/wxa/component/fastregisterpersonalweapp?action=create";
127+
128+
/**
129+
* 查询快速创建个人小程序任务状态接口.
130+
*/
131+
String FAST_REGISTER_PERSONAL_WEAPP_SEARCH_URL = "https://api.weixin.qq.com/wxa/component/fastregisterpersonalweapp?action=query";
132+
133+
/**
134+
* 快速创建试用小程序接口.
135+
*/
136+
String FAST_REGISTER_BETA_WEAPP_URL = "https://api.weixin.qq.com/wxa/component/fastregisterbetaweapp";
137+
123138
/**
124139
* 代小程序实现业务.
125140
* 小程序代码模版库管理:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1506504150_nMMh6&token=&lang=zh_CN
@@ -581,6 +596,39 @@ public interface WxOpenComponentService {
581596
WxOpenResult fastRegisterWeappSearch(String name, String legalPersonaWechat, String legalPersonaName) throws WxErrorException;
582597

583598

599+
/**
600+
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/fastregisterpersonalweapp.html
601+
* 快速创建个人小程序
602+
*
603+
* @param idname 个人用户名字
604+
* @param wxuser 个人用户微信号
605+
* @param componentPhone 第三方联系电话
606+
* @return the wx open result
607+
* @throws WxErrorException
608+
*/
609+
WxOpenRegisterPersonalWeappResult fastRegisterPersonalWeapp(String idname, String wxuser, String componentPhone) throws WxErrorException;
610+
611+
/**
612+
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/fastregisterpersonalweapp.html
613+
* 查询个人小程序注册任务状态
614+
*
615+
* @param taskid 任务ID
616+
* @return the wx open result
617+
* @throws WxErrorException
618+
*/
619+
WxOpenRegisterPersonalWeappResult fastRegisterPersonalWeappSearch(String taskid) throws WxErrorException;
620+
621+
/**
622+
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/beta_Mini_Programs/fastregister.html
623+
* 注册试用小程序
624+
*
625+
* @param name 小程序名称
626+
* @param openid 微信用户的openid(不是微信号)
627+
* @return the wx open result
628+
* @throws WxErrorException
629+
*/
630+
WxOpenRegisterBetaWeappResult fastRegisterBetaWeapp(String name, String openid) throws WxErrorException;
631+
584632
/**
585633
* https://api.weixin.qq.com/product/register/register_shop?component_access_token=xxxxxxxxx
586634
* 注册小商店账号

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,34 @@ public WxOpenResult fastRegisterWeappSearch(String name, String legalPersonaWech
626626
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
627627
}
628628

629+
@Override
630+
public WxOpenRegisterPersonalWeappResult fastRegisterPersonalWeapp(String idname, String wxuser, String componentPhone) throws WxErrorException {
631+
JsonObject jsonObject = new JsonObject();
632+
jsonObject.addProperty("idname", idname);
633+
jsonObject.addProperty("wxuser", wxuser);
634+
jsonObject.addProperty("component_phone", componentPhone);
635+
String response = post(FAST_REGISTER_PERSONAL_WEAPP_URL, jsonObject.toString(), "component_access_token");
636+
return WxOpenGsonBuilder.create().fromJson(response, WxOpenRegisterPersonalWeappResult.class);
637+
}
638+
639+
@Override
640+
public WxOpenRegisterPersonalWeappResult fastRegisterPersonalWeappSearch(String taskid) throws WxErrorException {
641+
JsonObject jsonObject = new JsonObject();
642+
jsonObject.addProperty("taskid", taskid);
643+
String response = post(FAST_REGISTER_PERSONAL_WEAPP_SEARCH_URL, jsonObject.toString(), "component_access_token");
644+
return WxOpenGsonBuilder.create().fromJson(response, WxOpenRegisterPersonalWeappResult.class);
645+
}
646+
647+
@Override
648+
public WxOpenRegisterBetaWeappResult fastRegisterBetaWeapp(String name, String openid) throws WxErrorException {
649+
JsonObject jsonObject = new JsonObject();
650+
jsonObject.addProperty("name", name);
651+
jsonObject.addProperty("openid", openid);
652+
String response = wxOpenService.getWxOpenComponentService()
653+
.post(FAST_REGISTER_BETA_WEAPP_URL, jsonObject.toString(), "access_token");
654+
return WxOpenGsonBuilder.create().fromJson(response, WxOpenRegisterBetaWeappResult.class);
655+
}
656+
629657
@Override
630658
public WxOpenResult registerShop(String wxName, String idCardName, String idCardNumber, String channelId, Integer apiOpenstoreType, String authPageUrl) throws WxErrorException {
631659
JsonObject jsonObject = new JsonObject();

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/message/WxOpenXmlMessage.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ public static class Info implements Serializable {
102102
@XStreamAlias("component_phone")
103103
@XStreamConverter(value = XStreamCDataConverter.class)
104104
private String componentPhone;
105+
106+
// 创建个人小程序审核通知数据
107+
@XStreamAlias("wxuser")
108+
@XStreamConverter(value = XStreamCDataConverter.class)
109+
private String wxuser;
110+
111+
@XStreamAlias("idname")
112+
@XStreamConverter(value = XStreamCDataConverter.class)
113+
private String idname;
114+
115+
// 创建试用小程序成功/失败的通知数据
116+
@XStreamAlias("unique_id")
117+
@XStreamConverter(value = XStreamCDataConverter.class)
118+
private String uniqueId;
119+
105120
}
106121

107122
public static String wxMpOutXmlMessageToEncryptedXml(WxMpXmlOutMessage message, WxOpenConfigStorage wxOpenConfigStorage) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package me.chanjar.weixin.open.bean.result;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
7+
@Data
8+
@EqualsAndHashCode(callSuper = true)
9+
public class WxOpenRegisterBetaWeappResult extends WxOpenResult {
10+
@SerializedName("authorize_url")
11+
private String authorizeUrl;
12+
@SerializedName("unique_id")
13+
protected String uniqueId;
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package me.chanjar.weixin.open.bean.result;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
7+
@Data
8+
@EqualsAndHashCode(callSuper = true)
9+
public class WxOpenRegisterPersonalWeappResult extends WxOpenResult {
10+
private String taskid;
11+
@SerializedName("authorize_url")
12+
private String authorizeUrl;
13+
@SerializedName("status")
14+
private Integer status;
15+
}

0 commit comments

Comments
 (0)