Skip to content

Commit 7f7c0a3

Browse files
authored
🆕 #2815【开放平台】查询公众号/小程序是否绑定open实现 && 增加授权用户资料变更事件常量
1 parent b8d0baa commit 7f7c0a3

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java

+16
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,23 @@ public static class EventType {
309309
*/
310310
public static final String LOCATION_SELECT = "location_select";
311311

312+
/**
313+
* 授权用户资料变更事件
314+
* 1、 当部分用户的资料存在风险时,平台会对用户资料进行清理,并通过消息推送服务器通知最近30天授权过的公众号开发者,我们建议开发者留意响应该事件,及时主动更新或清理用户的头像及昵称,降低风险。
315+
* 2、 当用户撤回授权信息时,平台会通过消息推送服务器通知给公众号开发者,请开发者注意及时删除用户信息。
316+
*/
317+
public static final String USER_INFO_MODIFIED = "user_info_modified";
318+
319+
/**
320+
* 用户撤回授权事件
321+
*/
322+
public static final String USER_AUTHORIZATION_REVOKE = "user_authorization_revoke";
323+
324+
/**
325+
* 群发模板回调事件
326+
*/
312327
public static final String TEMPLATE_SEND_JOB_FINISH = "TEMPLATESENDJOBFINISH";
328+
313329
/**
314330
* 微信小店 订单付款通知.
315331
*/

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

+15
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ public interface WxOpenComponentService {
115115
*/
116116
String GET_OPEN_URL = "https://api.weixin.qq.com/cgi-bin/open/get";
117117

118+
/**
119+
* 查询公众号/小程序是否绑定 open 帐号
120+
*/
121+
String HAVE_OPEN_URL = "https://api.weixin.qq.com/cgi-bin/open/have";
122+
118123
/**
119124
* 快速创建小程序接口.
120125
*/
@@ -575,6 +580,16 @@ public interface WxOpenComponentService {
575580
*/
576581
WxOpenGetResult getOpenAccount(String appId, String appIdType) throws WxErrorException;
577582

583+
/**
584+
* https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/getbindopeninfo.html
585+
* 查询公众号/小程序是否绑定 open 帐号
586+
*
587+
* @return 是否绑定 open 帐号,true表示绑定;false表示未绑定任何 open 帐号
588+
* @throws WxErrorException the wx error exception
589+
*/
590+
WxOpenHaveResult haveOpen() throws WxErrorException;
591+
592+
578593
/**
579594
* https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21538208049W8uwq&token=&lang=zh_CN
580595
* 第三方平台快速创建小程序.

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

+6
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,12 @@ public WxOpenGetResult getOpenAccount(String appId, String appIdType) throws WxE
607607
return WxOpenGetResult.fromJson(json);
608608
}
609609

610+
@Override
611+
public WxOpenHaveResult haveOpen() throws WxErrorException {
612+
String json = post(GET_OPEN_URL, null);
613+
return WxOpenHaveResult.fromJson(json);
614+
}
615+
610616

611617
@Override
612618
public WxOpenResult fastRegisterWeapp(String name, String code, String codeType, String legalPersonaWechat, String legalPersonaName, String componentPhone) throws WxErrorException {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* 该 API 用于查询公众号或小程序是否绑定的开放平台帐号。
12+
* 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/getbindopeninfo.html
13+
*/
14+
@Data
15+
@EqualsAndHashCode(callSuper = false)
16+
public class WxOpenHaveResult extends WxOpenResult implements Serializable {
17+
18+
@SerializedName("have_open")
19+
private Boolean haveOpen;
20+
21+
public static WxOpenHaveResult fromJson(String json) {
22+
return WxGsonBuilder.create().fromJson(json, WxOpenHaveResult.class);
23+
}
24+
25+
}

weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImplTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.inject.Inject;
44
import me.chanjar.weixin.common.error.WxErrorException;
55
import me.chanjar.weixin.open.api.WxOpenComponentService;
6+
import me.chanjar.weixin.open.bean.result.WxOpenHaveResult;
67
import me.chanjar.weixin.open.bean.result.WxOpenResult;
78
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvRequest;
89
import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvResponse;
@@ -166,6 +167,11 @@ public void testUnbindOpenAccount() {
166167
@Test
167168
public void testGetOpenAccount() {
168169
}
170+
@Test
171+
public void testHaveOpen() throws WxErrorException {
172+
WxOpenHaveResult wxOpenHaveResult = wxOpenComponentService.haveOpen();
173+
Assert.assertNotNull(wxOpenHaveResult);
174+
}
169175

170176
@Test
171177
public void testFastRegisterWeapp() {

0 commit comments

Comments
 (0)