public class Test {
public static void main(String[] args) throws Exception {
String userId = "ee7fe7fbda";
String secretkey = "2owGBAZsAY";
String url = "https://api.polyv.net/v2/video/engagement/%s/getList";
Map<String, String> maps = new HashMap<>();
maps.put("field", "viewer");
maps.put("fieldValue", "1111");
maps.put("filterValue", "");
maps.put("sign", getSign(maps, secretkey));
url += "?" + buildUrl(maps);
url = String.format(url, userId);
HttpClient client = new HttpClient();
GetMethod getMethod = new GetMethod(url);
client.executeMethod(getMethod);
System.out.println(url);
System.out.println(getMethod.getResponseBodyAsString());
}
public static String buildUrl(Map<String, String> maps) {
List<String> tmp = new ArrayList<>();
for (Map.Entry<String, String> key : maps.entrySet()) {
tmp.add(key.getKey() + "=" + key.getValue());
}
return String.join("&", tmp);
}
}