mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🆕 【企业微信】新增获取企业微信接口IP段的接口 !126
This commit is contained in:
parent
e5255ed6ce
commit
47dba7f04f
@ -149,7 +149,7 @@ public interface WxCpService extends WxService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取微信服务器的ip段
|
||||
* 获取企业微信回调IP段
|
||||
* http://qydev.weixin.qq.com/wiki/index.php?title=回调模式#.E8.8E.B7.E5.8F.96.E5.BE.AE.E4.BF.A1.E6.9C.8D.E5.8A.A1.E5.99.A8.E7.9A.84ip.E6.AE.B5
|
||||
* </pre>
|
||||
*
|
||||
@ -158,6 +158,17 @@ public interface WxCpService extends WxService {
|
||||
*/
|
||||
String[] getCallbackIp() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取企业微信接口IP段
|
||||
* https://developer.work.weixin.qq.com/document/path/92520
|
||||
* </pre>
|
||||
*
|
||||
* @return 企业微信接口IP段
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
String[] getApiDomainIp() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取服务商凭证
|
||||
|
@ -229,7 +229,23 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH
|
||||
|
||||
@Override
|
||||
public String[] getCallbackIp() throws WxErrorException {
|
||||
String responseContent = get(this.configStorage.getApiUrl(GET_CALLBACK_IP), null);
|
||||
return getIp(GET_CALLBACK_IP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getApiDomainIp() throws WxErrorException {
|
||||
return getIp(GET_API_DOMAIN_IP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 IP
|
||||
*
|
||||
* @param suffixUrl 接口URL 后缀
|
||||
* @return 返回结果
|
||||
* @throws WxErrorException 异常信息
|
||||
*/
|
||||
private String[] getIp(String suffixUrl) throws WxErrorException {
|
||||
String responseContent = get(this.configStorage.getApiUrl(suffixUrl), null);
|
||||
JsonObject tmpJsonObject = GsonParser.parse(responseContent);
|
||||
JsonArray jsonArray = tmpJsonObject.get("ip_list").getAsJsonArray();
|
||||
String[] ips = new String[jsonArray.size()];
|
||||
|
@ -27,6 +27,10 @@ public interface WxCpApiPathConsts {
|
||||
* The constant GET_CALLBACK_IP.
|
||||
*/
|
||||
String GET_CALLBACK_IP = "/cgi-bin/getcallbackip";
|
||||
/**
|
||||
* The constant GET_API_DOMAIN_IP.
|
||||
*/
|
||||
String GET_API_DOMAIN_IP = "/cgi-bin/get_api_domain_ip";
|
||||
/**
|
||||
* The constant BATCH_REPLACE_PARTY.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user