I have signed the post data.
URL getUrl = new URL("
https://bter.com/api/1/private/orderlist");
HttpURLConnection aConnection = (HttpURLConnection) getUrl
.openConnection();
Map<String, String> data = new HashMap<String, String>();
// data.put("dad", "fff");
// data.put("order_id", "fff");
data.put("nonce", String.valueOf(System.currentTimeMillis()));
String postdata = httpBuildQuery(data);
String sign = generateHMAC(postdata);
aConnection.setRequestMethod("POST");
//aConnection.setDoOutput(true);
aConnection.setRequestProperty("Key",
"*************");
aConnection.setRequestProperty("Sign", sign.replaceAll("\n", ""));
aConnection.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(
aConnection.getInputStream(), "utf-8"));
I dont know what is wrong.
private static String httpBuildQuery(Map<String, String> data)
throws UnsupportedEncodingException {
String result = new String();
for (String hashkey : data.keySet()) {
if (result.length() > 0) result += '&';
try {
result += URLEncoder.encode(hashkey, "UTF-8") + "="
+ URLEncoder.encode(data.get(hashkey), "UTF-8");
} catch (Exception ex) {
// Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
}
}
return result;
}