public static Uri getProfilePictureUri( String userId, int width, int height) { Validate.notNullOrEmpty(userId, "userId"); width = Math.max(width, UNSPECIFIED_DIMENSION); height = Math.max(height, UNSPECIFIED_DIMENSION); if (width == UNSPECIFIED_DIMENSION && height == UNSPECIFIED_DIMENSION) { throw new IllegalArgumentException("Either width or height must be greater than 0"); } Uri.Builder builder = Uri.parse(ServerProtocol.getGraphUrlBase()) .buildUpon() .path(String.format( Locale.US, PATH, FacebookSdk.getGraphApiVersion(), userId)); if (height != UNSPECIFIED_DIMENSION) { builder.appendQueryParameter(HEIGHT_PARAM, String.valueOf(height)); } if (width != UNSPECIFIED_DIMENSION) { builder.appendQueryParameter(WIDTH_PARAM, String.valueOf(width)); } builder.appendQueryParameter(MIGRATION_PARAM, MIGRATION_VALUE); return builder.build(); }
final String getRelativeUrlForBatchedRequest() { if (overriddenURL != null) { throw new FacebookException("Can't override URL for a batch request"); } String baseUrl = String.format("%s/%s", ServerProtocol.getGraphUrlBase(), getGraphPathWithVersion()); addCommonParameters(); String fullUrl = appendParametersToBaseUrl(baseUrl, true); Uri uri = Uri.parse(fullUrl); return String.format("%s?%s", uri.getPath(), uri.getQuery()); }
final String getUrlForSingleRequest() { if (overriddenURL != null) { return overriddenURL.toString(); } String graphBaseUrlBase; if (this.getHttpMethod() == HttpMethod.POST && graphPath != null && graphPath.endsWith(VIDEOS_SUFFIX)) { graphBaseUrlBase = ServerProtocol.getGraphVideoUrlBase(); } else { graphBaseUrlBase = ServerProtocol.getGraphUrlBase(); } String baseUrl = String.format("%s/%s", graphBaseUrlBase, getGraphPathWithVersion()); addCommonParameters(); return appendParametersToBaseUrl(baseUrl, false); }
url = new URL(ServerProtocol.getGraphUrlBase());
@Test public void testFacebookDomain() { FacebookSdk.setFacebookDomain("beta.facebook.com"); String graphUrlBase = ServerProtocol.getGraphUrlBase(); assertEquals("https://graph.beta.facebook.com", graphUrlBase); FacebookSdk.setFacebookDomain("facebook.com"); }
final String getUrlForSingleRequest() { if (overriddenURL != null) { return overriddenURL.toString(); } String graphBaseUrlBase; if (this.getHttpMethod() == HttpMethod.POST && graphPath != null && graphPath.endsWith(VIDEOS_SUFFIX)) { graphBaseUrlBase = ServerProtocol.getGraphVideoUrlBase(); } else { graphBaseUrlBase = ServerProtocol.getGraphUrlBase(); } String baseUrl = String.format("%s/%s", graphBaseUrlBase, getGraphPathWithVersion()); addCommonParameters(); return appendParametersToBaseUrl(baseUrl); }
url = new URL(ServerProtocol.getGraphUrlBase());