mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🆕 #2597 【开放平台】增加公众号业务相关的小程序管理接口
This commit is contained in:
parent
946f693bd0
commit
fcb0bc8c35
@ -238,6 +238,19 @@ public interface WxOpenMaService extends WxMaService {
|
||||
*/
|
||||
String API_AUDIT_UPLOAD_MEDIA = "https://api.weixin.qq.com/wxa/uploadmedia";
|
||||
|
||||
/**
|
||||
* 小程序管理-获取公众号关联的小程序
|
||||
*/
|
||||
String API_WX_AMP_LINK_GET = "https://api.weixin.qq.com/cgi-bin/wxopen/wxamplinkget";
|
||||
/**
|
||||
* 小程序管理-关联小程序
|
||||
*/
|
||||
String API_WX_AMP_LINK_CREATE = "https://api.weixin.qq.com/cgi-bin/wxopen/wxamplink";
|
||||
/**
|
||||
* 小程序管理-解除已关联的小程序
|
||||
*/
|
||||
String API_WX_AMP_LINK_UN = "https://api.weixin.qq.com/cgi-bin/wxopen/wxampunlink";
|
||||
|
||||
/**
|
||||
* 获得小程序的域名配置信息
|
||||
*
|
||||
@ -645,4 +658,48 @@ public interface WxOpenMaService extends WxMaService {
|
||||
* @return
|
||||
*/
|
||||
WxMaAuditMediaUploadResult uploadMedia(File file) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取公众号关联的小程序
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址:<a href="https://api.weixin.qq.com/cgi-bin/wxopen/wxamplinkget?access_token=TOKEN">https://api.weixin.qq.com/cgi-bin/wxopen/wxamplinkget?access_token=TOKEN</a>
|
||||
* 文档地址:<a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Official__Accounts/Mini_Program_Management_Permission.html">https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Official__Accounts/Mini_Program_Management_Permission.html</a>
|
||||
* <pre>
|
||||
* @return 公众号关联的小程序
|
||||
*/
|
||||
WxAmpLinkResult getWxAmpLink() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 关联小程序
|
||||
* 关联流程(需要公众号和小程序管理员双方确认):
|
||||
* 1、第三方平台调用接口发起关联
|
||||
* 2、公众号管理员收到模板消息,同意关联小程序。
|
||||
* 3、小程序管理员收到模板消息,同意关联公众号。
|
||||
* 4、关联成功
|
||||
* 等待管理员同意的中间状态可使用“获取公众号关联的小程序”接口进行查询。
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址:<a href="https://api.weixin.qq.com/cgi-bin/wxopen/wxamplink?access_token=TOKEN">https://api.weixin.qq.com/cgi-bin/wxopen/wxamplink?access_token=TOKEN</a>
|
||||
* 文档地址:<a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Official__Accounts/Mini_Program_Management_Permission.html">https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Official__Accounts/Mini_Program_Management_Permission.html</a>
|
||||
* <pre>
|
||||
* @param appid 小程序 appid
|
||||
* @param notifyUsers 是否发送模板消息通知公众号粉丝
|
||||
* @param showProfile 是否展示公众号主页中
|
||||
* @return 响应结果
|
||||
*/
|
||||
WxOpenResult wxAmpLink(String appid, String notifyUsers, String showProfile) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 解除已关联的小程序
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址:<a href="https://api.weixin.qq.com/cgi-bin/wxopen/wxampunlink?access_token=TOKEN">https://api.weixin.qq.com/cgi-bin/wxopen/wxampunlink?access_token=TOKEN</a>
|
||||
* 文档地址:<a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Official__Accounts/Mini_Program_Management_Permission.html">https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Official__Accounts/Mini_Program_Management_Permission.html</a>
|
||||
* <pre>
|
||||
* @param appid 小程序 appid
|
||||
* @return 响应结果
|
||||
*/
|
||||
WxOpenResult wxAmpUnLink(String appid) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
@ -406,6 +406,30 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
|
||||
return (WxMaAuditMediaUploadResult) this.execute(AuditMediaUploadRequestExecutor.create(getRequestHttp()), API_AUDIT_UPLOAD_MEDIA, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxAmpLinkResult getWxAmpLink() throws WxErrorException {
|
||||
String response = post(API_WX_AMP_LINK_GET, "{}");
|
||||
return WxMaGsonBuilder.create().fromJson(response, WxAmpLinkResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOpenResult wxAmpLink(String appid, String notifyUsers, String showProfile) throws WxErrorException {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("appid", appid);
|
||||
params.addProperty("notify_users", notifyUsers);
|
||||
params.addProperty("show_profile", showProfile);
|
||||
String response = post(API_WX_AMP_LINK_CREATE, GSON.toJson(params));
|
||||
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOpenResult wxAmpUnLink(String appid) throws WxErrorException {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("appid", appid);
|
||||
String response = post(API_WX_AMP_LINK_UN, GSON.toJson(params));
|
||||
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
|
||||
}
|
||||
|
||||
private JsonArray toJsonArray(List<String> strList) {
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
if (strList != null && !strList.isEmpty()) {
|
||||
|
@ -0,0 +1,111 @@
|
||||
package me.chanjar.weixin.open.bean.result;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公众号关联的小程序
|
||||
*
|
||||
* @author zhongjun
|
||||
* @date 2022/4/29
|
||||
**/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxAmpLinkResult extends WxOpenResult{
|
||||
|
||||
/**
|
||||
* 关联的小程序列表,具有 items 字段,内带有参数
|
||||
*/
|
||||
@SerializedName("wxopens")
|
||||
private WxOpen wxOpen;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class WxOpen{
|
||||
@SerializedName("items")
|
||||
private List<Item> items;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Item{
|
||||
|
||||
/**
|
||||
* 关联状态
|
||||
* 1:已关联;
|
||||
* 2:等待小程序管理员确认中;
|
||||
* 3:小程序管理员拒绝关联
|
||||
* 12:等待公众号管理员确认中;
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 小程序appid
|
||||
*/
|
||||
private String appid;
|
||||
|
||||
/**
|
||||
* 小程序 gh_id
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 小程序名称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 是否在公众号管理页展示中
|
||||
*/
|
||||
private Integer selected;
|
||||
|
||||
/**
|
||||
* 是否展示在附近的小程序中
|
||||
*/
|
||||
@SerializedName("nearby_display_status")
|
||||
private Integer nearbyDisplayStatus;
|
||||
|
||||
/**
|
||||
* 是否已经发布
|
||||
*/
|
||||
private Integer released;
|
||||
|
||||
/**
|
||||
* 头像 url
|
||||
*/
|
||||
@SerializedName("headimg_url")
|
||||
private String headImgUrl;
|
||||
|
||||
/**
|
||||
* 小程序邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 微信认证及支付信息
|
||||
*/
|
||||
@SerializedName("func_info")
|
||||
private List<FuncInfo> funcInfo;
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class FuncInfo{
|
||||
/**
|
||||
* 微信认证及支付信息,0 表示未开通,1 表示开通
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long id;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user