企业号:新增获取微信服务器IP地址接口&调整回调模式下的首次验证的签名方式
This commit is contained in:
@@ -61,3 +61,5 @@ weixin.properties说明
|
||||
* 2014-12-28
|
||||
|
||||
+ 增加`批量获取用户详情`的接口
|
||||
|
||||
+ 新增`获取微信服务器IP`接口
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.JsonResult;
|
||||
import com.foxinmy.weixin4j.model.WeixinQyAccount;
|
||||
import com.foxinmy.weixin4j.qy.api.DepartApi;
|
||||
import com.foxinmy.weixin4j.qy.api.HelperApi;
|
||||
import com.foxinmy.weixin4j.qy.api.TagApi;
|
||||
import com.foxinmy.weixin4j.qy.api.UserApi;
|
||||
import com.foxinmy.weixin4j.qy.model.Department;
|
||||
@@ -29,6 +30,7 @@ public class WeixinProxy {
|
||||
private final DepartApi departApi;
|
||||
private final UserApi userApi;
|
||||
private final TagApi tagApi;
|
||||
private final HelperApi helperApi;
|
||||
|
||||
/**
|
||||
* 默认采用文件存放Token信息
|
||||
@@ -65,6 +67,7 @@ public class WeixinProxy {
|
||||
this.departApi = new DepartApi(tokenHolder);
|
||||
this.userApi = new UserApi(tokenHolder);
|
||||
this.tagApi = new TagApi(tokenHolder);
|
||||
this.helperApi = new HelperApi(tokenHolder);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,4 +345,17 @@ public class WeixinProxy {
|
||||
throws WeixinException {
|
||||
return tagApi.deleteTagUsers(tagId, userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信服务器IP地址
|
||||
*
|
||||
* @return IP地址
|
||||
* @see com.foxinmy.weixin4j.qy.api.HelperApi
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%9B%9E%E8%B0%83%E6%A8%A1%E5%BC%8F#.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">获取IP地址</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<String> getcallbackip() throws WeixinException {
|
||||
return helperApi.getcallbackip();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.foxinmy.weixin4j.qy.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.Response;
|
||||
import com.foxinmy.weixin4j.model.Token;
|
||||
import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
|
||||
/**
|
||||
* 辅助API
|
||||
*
|
||||
* @className HelperApi
|
||||
* @author jy
|
||||
* @date 2014年12月28日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public class HelperApi extends QyApi {
|
||||
private final TokenHolder tokenHolder;
|
||||
|
||||
public HelperApi(TokenHolder tokenHolder) {
|
||||
this.tokenHolder = tokenHolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信服务器IP地址
|
||||
*
|
||||
* @return IP地址
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%9B%9E%E8%B0%83%E6%A8%A1%E5%BC%8F#.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">获取IP地址</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<String> getcallbackip() throws WeixinException {
|
||||
String getcallbackip_uri = getRequestUri("getcallbackip_uri");
|
||||
Token token = tokenHolder.getToken();
|
||||
Response response = request.post(String.format(getcallbackip_uri,
|
||||
token.getAccessToken()));
|
||||
return JSON.parseArray(response.getAsJson().getString("ip_list"),
|
||||
String.class);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -54,4 +54,6 @@ menu_delete_uri={api_base_url}/menu/delete?access_token=%s&agentid=%d
|
||||
# \u67e5\u8be2\u83dc\u5355
|
||||
menu_get_uri={api_base_url}/menu/get?access_token=%s&agentid=%d
|
||||
# \u53d1\u9001\u6d88\u606f
|
||||
message_send_uri={api_base_url}/message/send?access_token=%s
|
||||
message_send_uri={api_base_url}/message/send?access_token=%s
|
||||
# \u83b7\u53d6\u5fae\u4fe1IP\u5730\u5740
|
||||
getcallbackip_uri={api_base_url}/getcallbackip?access_token=%s
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.foxinmy.weixin4j.qy.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.qy.api.HelperApi;
|
||||
|
||||
/**
|
||||
* 辅助API测试
|
||||
*
|
||||
* @className HelperTest
|
||||
* @author jy
|
||||
* @date 2014年12月28日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public class HelperTest extends TokenTest {
|
||||
public HelperApi helperApi;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
this.helperApi = new HelperApi(tokenHolder);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void backip() throws WeixinException {
|
||||
List<String> ips = helperApi.getcallbackip();
|
||||
Assert.assertTrue(ips != null && !ips.isEmpty());
|
||||
System.out.println(ips);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user