Skip to content

Commit 2a45fe4

Browse files
authored
🆕 #1902 【企业微信】增加获取加入企业二维码的接口
1 parent 8f3fa1d commit 2a45fe4

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpUserService.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,20 @@ public interface WxCpUserService {
183183
*/
184184
WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException;
185185

186-
186+
/**
187+
* <pre>
188+
*
189+
* 获取加入企业二维码。
190+
*
191+
* 请求方式:GET(HTTPS)
192+
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/corp/get_join_qrcode?access_token=ACCESS_TOKEN&size_type=SIZE_TYPE
193+
*
194+
* 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/91714
195+
* </pre>
196+
*
197+
* @param sizeType qrcode尺寸类型,1: 171 x 171; 2: 399 x 399; 3: 741 x 741; 4: 2052 x 2052
198+
* @return join_qrcode 二维码链接,有效期7天
199+
* @throws WxErrorException .
200+
*/
201+
String getJoinQrCode(int sizeType) throws WxErrorException;
187202
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpUserServiceImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package me.chanjar.weixin.cp.api.impl;
22

33
import com.google.common.collect.Maps;
4-
import com.google.gson.*;
4+
import com.google.gson.JsonArray;
5+
import com.google.gson.JsonObject;
6+
import com.google.gson.JsonPrimitive;
57
import com.google.gson.reflect.TypeToken;
68
import lombok.RequiredArgsConstructor;
79
import me.chanjar.weixin.common.error.WxErrorException;
@@ -198,4 +200,12 @@ public WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorE
198200
String responseContent = this.mainService.get(url, null);
199201
return WxCpExternalContactInfo.fromJson(responseContent);
200202
}
203+
204+
@Override
205+
public String getJoinQrCode(int sizeType) throws WxErrorException {
206+
String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_JOIN_QR_CODE + sizeType);
207+
String responseContent = this.mainService.get(url, null);
208+
JsonObject tmpJson = GsonParser.parse(responseContent);
209+
return tmpJson.get("join_qrcode").getAsString();
210+
}
201211
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public static class User {
161161
public static final String USER_CONVERT_TO_USERID = "/cgi-bin/user/convert_to_userid";
162162
public static final String GET_USER_ID = "/cgi-bin/user/getuserid";
163163
public static final String GET_EXTERNAL_CONTACT = "/cgi-bin/crm/get_external_contact?external_userid=";
164+
public static final String GET_JOIN_QR_CODE = "/cgi-bin/corp/get_join_qrcode?size_type=";
164165
}
165166

166167
@UtilityClass

0 commit comments

Comments
 (0)