Skip to content

Instantly share code, notes, and snippets.

/Cryptsy.java Secret

Created August 4, 2015 20:49
Show Gist options
  • Save anonymous/8c128bdab19b44eec2f7 to your computer and use it in GitHub Desktop.
Save anonymous/8c128bdab19b44eec2f7 to your computer and use it in GitHub Desktop.
HttpURLConnection connection;
URL url = new URL("https://api.cryptsy.com/api/v2/" + params);
connection = (HttpURLConnection) url.openConnection();
params += "&nonce=" + System.currentTimeMillis() / 1000L;
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length",
Integer.toString(params.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
String sign = generateHMAC(params);
connection.setRequestProperty("Sign",sign);
connection.setRequestProperty("Key",pubKey);
connection.setUseCaches(false);
connection.setDoOutput(true);
//Send request
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(params);
wr.close();
System.out.println("Sent");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment