Package facebook4j.internal.http

Examples of facebook4j.internal.http.HttpResponse


        return Boolean.valueOf(res.asString().trim());
    }

    public boolean makeFriendTestUser(TestUser testUser1, TestUser testUser2) throws FacebookException {
        ensureAuthorizationEnabled();
        HttpResponse res = post(buildEndpoint(testUser1.getId(), "friends/" + testUser2.getId()),
                                new HttpParameter[]{new HttpParameter("access_token", testUser1.getAccessToken())});
        if (!Boolean.valueOf(res.asString().trim())) {
            return false;
        }
        res = post(buildEndpoint(testUser2.getId(), "friends/" + testUser1.getId()),
                                new HttpParameter[]{new HttpParameter("access_token", testUser2.getAccessToken())});
        return Boolean.valueOf(res.asString().trim());
    }
View Full Code Here


        return (ResponseList<T>) fetchPaging(url, paging.getJSONObjectType());
    }

    private <T> ResponseList<T> fetchPaging(URL url, Class<T> jsonObjectType) throws FacebookException {
        ensureAuthorizationEnabled();
        HttpResponse res = getRaw(url.toString());
        return (ResponseList<T>) factory.createResponseList(res, jsonObjectType);
    }
View Full Code Here

        if (relativeUrl.startsWith("/")) {
            path = relativeUrl.substring(1);
        }

        // not supports "JSONStore" option because this method returns the json object itself.
        HttpResponse res = get(buildEndpoint(path, parameters));
        return new RawAPIResponseImpl(res);
    }
View Full Code Here

        String path = relativeUrl;
        if (relativeUrl.startsWith("/")) {
            path = relativeUrl.substring(1);
        }

        HttpResponse res;
        if (parameters != null && parameters.size() > 0) {
            final HttpParameter[] httpParameters = new HttpParameter[parameters.size()];
            int i = 0;
            for (final String p : parameters.keySet()) {
                httpParameters[i++] = new HttpParameter(p, parameters.get(p));
View Full Code Here

        if (relativeUrl.startsWith("/")) {
            path = relativeUrl.substring(1);
        }

        // not supports "JSONStore" option because this method returns the json object itself.
        HttpResponse res = delete(buildEndpoint(path, parameters));
        return new RawAPIResponseImpl(res);
    }
View Full Code Here

        return factory.createLikeList(get(buildEndpoint(objectId, "likes", reading)));
    }

    private URL _getPictureURL(String objectId, PictureSize size) throws FacebookException {
        String url = buildEndpoint(objectId, "picture");
        HttpResponse res;
        if (size != null) {
            res = get(url, new HttpParameter[]{new HttpParameter("type", size.toString())});
        } else {
            res = get(url);
        }
        try {
            return new URL(res.getResponseHeader("Location"));
        } catch (MalformedURLException urle) {
            throw new FacebookException(urle.getMessage(), urle);
        }
    }
View Full Code Here

        }
    }

    private URL _getSSLPictureURL(String objectId, PictureSize size) throws FacebookException {
        String url = buildEndpoint(objectId, "picture");
        HttpResponse res;
        HttpParameter[] params = new HttpParameter[]{new HttpParameter("return_ssl_resources", "1")};
        if (size != null) {
            params = HttpParameter.merge(params, new HttpParameter("type", size.toString()));
        }
        res = get(url, params);
        try {
            return new URL(res.getResponseHeader("Location"));
        } catch (MalformedURLException urle) {
            throw new FacebookException(urle.getMessage(), urle);
        }
    }
View Full Code Here

        }
    }

    private boolean _like(String objectId) throws FacebookException {
        ensureAuthorizationEnabled();
        HttpResponse res = post(buildEndpoint(objectId, "likes"));
        return Boolean.valueOf(res.asString().trim());
    }
View Full Code Here

        return Boolean.valueOf(res.asString().trim());
    }

    private boolean _unlike(String objectId) throws FacebookException {
        ensureAuthorizationEnabled();
        HttpResponse res = delete(buildEndpoint(objectId, "likes"));
        return Boolean.valueOf(res.asString().trim());
    }
View Full Code Here

    private HttpResponse get(String url) throws FacebookException {
        if (!conf.isMBeanEnabled()) {
            return http.get(url, auth);
        } else {
            // intercept HTTP call for monitoring purposes
            HttpResponse response = null;
            long start = System.currentTimeMillis();
            try {
                response = http.get(url, auth);
            } finally {
                long elapsedTime = System.currentTimeMillis() - start;
View Full Code Here

TOP

Related Classes of facebook4j.internal.http.HttpResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.