/** * */ package com.hexagrid.samples; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; import java.util.HashMap; /** * * */ public class LicenseClient { private static final String WHMCS_LIC_URL = "http:///scart/modules/servers/licensing/verify.php"; String localKey=null; private String check_license() throws Exception { String queryString = ""; HashMap postOpts = new HashMap(); postOpts.put("licensekey", "Partner-eea43e7b081fd958bfc4"); postOpts.put("domain", "www.anduril.com"); postOpts.put("ip", "192.168.155.121"); postOpts.put("dir", "/usr/bin"); HttpURLConnection con = (HttpURLConnection) new URL(WHMCS_LIC_URL).openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); con.setRequestProperty("Content-length", String.valueOf(queryString.length())); con.setRequestProperty("Connection", "close"); con.setDoOutput(true); con.setReadTimeout(1000 * 5); for(String key : postOpts.keySet()){ queryString+=URLEncoder.encode(postOpts.get(key)+"&","UTF-8"); } OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream()); wr.write(queryString); wr.flush(); BufferedReader rd = new BufferedReader(new InputStreamReader(con.getInputStream())); System.out.println(con.getContent()); String line; while ((line = rd.readLine()) != null) { System.out.println(line); } wr.close(); rd.close(); return "Test"; } /** * @param args */ public static void main(String[] args) throws Exception{ // TODO Auto-generated method stub LicenseClient lic = new LicenseClient(); lic.check_license(); } }