Skip to content

Commit

Permalink
🆕 #2832【企业微信】新增将代开发应用或第三方应用获取的externaluserid转换成自建应用的externaluserid的接口
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyingcanfeng authored Oct 7, 2022
1 parent 4ca4dec commit 8a161cf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,23 @@ public interface WxCpExternalContactService {
*/
String toServiceExternalUserid(String externalUserid) throws WxErrorException;

/**
* 将代开发应用或第三方应用获取的externaluserid转换成自建应用的externaluserid
* <pre>
* 文档地址:https://developer.work.weixin.qq.com/document/path/95884#external-userid%E8%BD%AC%E6%8D%A2
*
* 权限说明:
*
* 需要使用自建应用或基础应用的access_token
* 客户的跟进人,或者用户所在客户群的群主,需要同时在access_token和source_agentid所对应应用的可见范围内
* </pre>
* @param externalUserid 服务商主体的external_userid,必须是source_agentid对应的应用所获取
* @param sourceAgentId 企业授权的代开发自建应用或第三方应用的agentid
* @return
* @throws WxErrorException
*/
String fromServiceExternalUserid(String externalUserid, String sourceAgentId) throws WxErrorException;

/**
* 企业客户微信unionid的升级 - unionid查询external_userid
* <pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ public String toServiceExternalUserid(String externalUserid) throws WxErrorExcep
return tmpJson.get("external_userid").getAsString();
}

@Override
public String fromServiceExternalUserid(String externalUserid, String sourceAgentId) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("external_userid", externalUserid);
json.addProperty("source_agentid", sourceAgentId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(FROM_SERVICE_EXTERNAL_USERID);
String responseContent = this.mainService.post(url, json.toString());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("external_userid").getAsString();
}
@Override
public WxCpExternalUserIdList unionidToExternalUserid3rd(String unionid, String openid,
String corpid) throws WxErrorException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,10 @@ interface ExternalContact {
* The constant TO_SERVICE_EXTERNAL_USERID.
*/
String TO_SERVICE_EXTERNAL_USERID = "/cgi-bin/externalcontact/to_service_external_userid";
/**
* The constant FROM_SERVICE_EXTERNAL_USERID.
*/
String FROM_SERVICE_EXTERNAL_USERID = "/cgi-bin/externalcontact/from_service_external_userid";
/**
* The constant FINISH_EXTERNAL_USERID_MIGRATION.
*/
Expand Down

0 comments on commit 8a161cf

Please sign in to comment.