Skip to content

【企业微信】新增API: 将代开发应用或第三方应用获取的externaluserid转换成自建应用的externaluserid #2832

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

Merged
merged 1 commit into from
Oct 7, 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 @@ -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