Garmaine Staff asked 2 years ago

I am trying to use this api to get report with java, and here is the link

and here is what i am using now

public static String getGraph() {
        String graph = "";
    try {
        URL urUserInfo = new URL(PROTECTED_RESOURCE_URL + "access_token");
        HttpURLConnection connObtainUserInfo = (HttpURLConnection) urUserInfo.openConnection();
        if (connObtainUserInfo.getResponseCode() == HttpURLConnection.HTTP_OK) {
            StringBuilder sbLines = new StringBuilder("");

            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(connObtainUserInfo.getInputStream(), "utf-8"));
            String strLine = "";
            while ((strLine = reader.readLine()) != null) {
            graph = sbLines.toString();
    } catch (IOException ex) {
    return graph;

I am pretty sure it's not a smart way to do that and the string I get is quite complex, are there any jave sample that i can get the data directly instead of using java origin httpRequest

Or, are there and class I can import to switch the json string to the object!?

Anyone can help?!

I have trying this for many days already!