java - Hashmap to query -
i working on html5+js api based website, can apk java sources api, because there no documentation.
i got api raw urls looking like: http://api-test.com/?key=value
but can trace wireshark apk never called raw urls directly , using rest api url looking this: http://api-test.com/rest/?key=value
the problem is, can't understand params sents via rest api, because rest api urls somehow hashed keys , values in this:
because not familar java @ all, possible somehow convert hashed data query?
this part java source code, think relating apis:
public picsearchresult picsearch(string isc, string q, string cid, int s, string rk, string shpc, string rg, string f, string cpid, string pid, int n, string isrtl, string ison) throws akserverstatusexception, akinvokeexception, aeresultexception { param2result<picsearchresult> response = this.picrawapi.pic_search("23b1k5ak91dll5d71s45h24l703la20d", isc, q, cid, s, rk, shpc, rg, f, cpid, pid, n, isrtl, ison); wsmobileresultchecker.check(response); return (picsearchresult) response.getbody(picsearchresult.class); } public interface picrawapi { @akapi(url = "http://test-api.com/") @akget param2result<picsearchresult> pic_search(@akparam("ak") string str, @akparam("isc") string str2, @akparam(encode = "utf-8", value = "q") string str3, @akparam("cid") string str4, @akparam("s") int i, @akparam("rk") string str5, @akparam("shpc") string str6, @akparam("rg") string str7, @akparam("f") string str8, @akparam("cpid") string str9, @akparam("pid") string str10, @akparam("n") int i2, @akparam("isrtl") string str11, @akparam("ison") string str12) throws akinvokeexception, akserverstatusexception; } private hashmap<string, string> getrawapiparams2hashmap(annotation[][] annosarr, object[] args, hashmap<string, file> filestosend, hashmap<string, string> paramsmapori) { hashmap<string, string> paramsmap = new hashmap(); (int idx = 0; idx < args.length; idx++) { string paramname = null; string encode = network.conn_type_none; (annotation : annosarr[idx]) { if (akparam.class.equals(a.annotationtype())) { akparam ap = (akparam) a; paramname = ap.value(); encode = ap.encode(); } } if (paramname != null) { map<string, string> arg = args[idx]; if (arg != null) { if (encode != null && !network.conn_type_none.equals(encode)) { try { paramsmap.put(paramname, urlencoder.encode(arg.tostring(), encode)); } catch (unsupportedencodingexception e) { log.m6w(tag, "unsupportedencodingexception:" + encode); paramsmap.put(paramname, arg.tostring()); } paramsmapori.put(paramname, arg.tostring()); } else if ("$parammap".equals(paramname)) { map<string, string> parammap = arg; paramsmap.putall(parammap); paramsmapori.putall(parammap); } else if (!"$filestosend".equals(paramname)) { paramsmap.put(paramname, arg.tostring()); paramsmapori.put(paramname, arg.tostring()); } else if (arg instanceof map) { filestosend.putall(arg); } } } } return paramsmap; } public static string encode(string str) { byte[] bytes = str.getbytes(); stringbuilder sb = new stringbuilder(bytes.length * 2); (int = 0; < bytes.length; i++) { sb.append(hexstring.charat((bytes[i] & 240) >> 4)); sb.append(hexstring.charat((bytes[i] & 15) >> 0)); } return sb.tostring(); } public static string decode(string bytes) { bytearrayoutputstream baos = new bytearrayoutputstream(bytes.length() / 2); (int = 0; < bytes.length(); += 2) { baos.write((hexstring.indexof(bytes.charat(i)) << 4) | hexstring.indexof(bytes.charat(i + 1))); } return new string(baos.tobytearray()); }
update2: trying conversion myself, catching errors :(
code:
public class helloworld { public static void main(string[] args) { string ap = "280f8a9454775de6a14d2b53da9088eb028bfe1a"; byte[] bytes = ap.getbytes(); bytearrayoutputstream baos = new bytearrayoutputstream(bytes.length() / 2); (int = 0; < bytes.length(); += 2) { baos.write((hexstring.indexof(bytes.charat(i)) << 4) | hexstring.indexof(bytes.charat(i + 1))); } system.out.println(baos.tobytearray()); } }
error:
sh-4.3$ javac helloworld.java helloworld.java:8: error: cannot find symbol bytearrayoutputstream baos = new bytearrayoutputstream(bytes.length() / 2); ^ symbol: class bytearrayoutputstream location: class helloworld helloworld.java:8: error: cannot find symbol bytearrayoutputstream baos = new bytearrayoutputstream(bytes.length() / 2); ^ symbol: class bytearrayoutputstream location: class helloworld helloworld.java:8: error: cannot find symbol bytearrayoutputstream baos = new bytearrayoutputstream(bytes.length() / 2); ^ symbol: method length() location: variable bytes of type byte[] helloworld.java:10: error: cannot find symbol (int = 0; < bytes.length(); += 2) { ^ symbol: method length() location: variable bytes of type byte[] helloworld.java:11: error: cannot find symbol baos.write((hexstring.indexof(bytes.charat(i)) << 4) | hexstring.indexof(bytes.charat(i + 1))); ^ symbol: method charat(int) location: variable bytes of type byte[] helloworld.java:11: error: cannot find symbol baos.write((hexstring.indexof(bytes.charat(i)) << 4) | hexstring.indexof(bytes.charat(i + 1))); ^ symbol: variable hexstring location: class helloworld helloworld.java:11: error: cannot find symbol baos.write((hexstring.indexof(bytes.charat(i)) << 4) | hexstring.indexof(bytes.charat(i + 1))); ^ symbol: method charat(int) location: variable bytes of type byte[] helloworld.java:11: error: cannot find symbol baos.write((hexstring.indexof(bytes.charat(i)) << 4) | hexstring.indexof(bytes.charat(i + 1))); ^ symbol: variable hexstring
coding ground link: http://www.tutorialspoint.com/compile_java_online.php?pid=0bw_cjbb95kqmtfrax2lytwjyuw8
Comments
Post a Comment