1 package com.foxinmy.weixin4j.qy.api;
2
3 import java.util.List;
4
5 import com.alibaba.fastjson.JSON;
6 import com.foxinmy.weixin4j.exception.WeixinException;
7 import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
8 import com.foxinmy.weixin4j.model.Token;
9 import com.foxinmy.weixin4j.token.TokenManager;
10
11
12
13
14
15
16
17
18
19
20 public class HelperApi extends QyApi {
21 private final TokenManager tokenManager;
22
23 public HelperApi(TokenManager tokenManager) {
24 this.tokenManager = tokenManager;
25 }
26
27
28
29
30
31
32
33
34
35 public List<String> getWechatServerIp() throws WeixinException {
36 String getcallbackip_uri = getRequestUri("getcallbackip_uri");
37 Token token = tokenManager.getCache();
38 WeixinResponse response = weixinExecutor.get(String.format(getcallbackip_uri,
39 token.getAccessToken()));
40 return JSON.parseArray(response.getAsJson().getString("ip_list"),
41 String.class);
42 }
43 }