Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【开放平台】查询公众号/小程序是否绑定open实现 && 增加授权用户资料变更事件常量 #2815

Merged
merged 3 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,23 @@ public static class EventType {
*/
public static final String LOCATION_SELECT = "location_select";

/**
* 授权用户资料变更事件
* 1、 当部分用户的资料存在风险时,平台会对用户资料进行清理,并通过消息推送服务器通知最近30天授权过的公众号开发者,我们建议开发者留意响应该事件,及时主动更新或清理用户的头像及昵称,降低风险。
* 2、 当用户撤回授权信息时,平台会通过消息推送服务器通知给公众号开发者,请开发者注意及时删除用户信息。
*/
public static final String USER_INFO_MODIFIED = "user_info_modified";

/**
* 用户撤回授权事件
*/
public static final String USER_AUTHORIZATION_REVOKE = "user_authorization_revoke";

/**
* 群发模板回调事件
*/
public static final String TEMPLATE_SEND_JOB_FINISH = "TEMPLATESENDJOBFINISH";

/**
* 微信小店 订单付款通知.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public interface WxOpenComponentService {
*/
String GET_OPEN_URL = "https://api.weixin.qq.com/cgi-bin/open/get";

/**
* 查询公众号/小程序是否绑定 open 帐号
*/
String HAVE_OPEN_URL = "https://api.weixin.qq.com/cgi-bin/open/have";

/**
* 快速创建小程序接口.
*/
Expand Down Expand Up @@ -575,6 +580,16 @@ public interface WxOpenComponentService {
*/
WxOpenGetResult getOpenAccount(String appId, String appIdType) throws WxErrorException;

/**
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/getbindopeninfo.html
* 查询公众号/小程序是否绑定 open 帐号
*
* @return 是否绑定 open 帐号,true表示绑定;false表示未绑定任何 open 帐号
* @throws WxErrorException the wx error exception
*/
WxOpenHaveResult haveOpen() throws WxErrorException;


/**
* https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21538208049W8uwq&token=&lang=zh_CN
* 第三方平台快速创建小程序.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,12 @@ public WxOpenGetResult getOpenAccount(String appId, String appIdType) throws WxE
return WxOpenGetResult.fromJson(json);
}

@Override
public WxOpenHaveResult haveOpen() throws WxErrorException {
String json = post(GET_OPEN_URL, null);
return WxOpenHaveResult.fromJson(json);
}


@Override
public WxOpenResult fastRegisterWeapp(String name, String code, String codeType, String legalPersonaWechat, String legalPersonaName, String componentPhone) throws WxErrorException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package me.chanjar.weixin.open.bean.result;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;

import java.io.Serializable;

/**
* 该 API 用于查询公众号或小程序是否绑定的开放平台帐号。
* 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/getbindopeninfo.html
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class WxOpenHaveResult extends WxOpenResult implements Serializable {

@SerializedName("have_open")
private Boolean haveOpen;

public static WxOpenHaveResult fromJson(String json) {
return WxGsonBuilder.create().fromJson(json, WxOpenHaveResult.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.api.WxOpenComponentService;
import me.chanjar.weixin.open.bean.result.WxOpenHaveResult;
import me.chanjar.weixin.open.bean.result.WxOpenResult;
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvRequest;
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvResponse;
Expand Down Expand Up @@ -166,6 +167,11 @@ public void testUnbindOpenAccount() {
@Test
public void testGetOpenAccount() {
}
@Test
public void testHaveOpen() throws WxErrorException {
WxOpenHaveResult wxOpenHaveResult = wxOpenComponentService.haveOpen();
Assert.assertNotNull(wxOpenHaveResult);
}

@Test
public void testFastRegisterWeapp() {
Expand Down