/** * @see com.restfb.BaseFacebookClient#createEndpointForApiCall(java.lang.String,boolean) */ @Override protected String createEndpointForApiCall(String apiCall, boolean hasAttachment) { while (apiCall.startsWith("/")) apiCall = apiCall.substring(1); String baseUrl = getFacebookGraphEndpointUrl(); if (hasAttachment && (apiCall.endsWith("/videos") || apiCall.endsWith("/advideos"))) { baseUrl = getFacebookGraphVideoEndpointUrl(); } else if (apiCall.endsWith("logout.php")) { baseUrl = getFacebookEndpointUrls().getFacebookEndpoint(); } return format("%s/%s", baseUrl, apiCall); }
/** * Returns the base endpoint URL for the Graph API. * * @return The base endpoint URL for the Graph API. */ protected String getFacebookGraphEndpointUrl() { if (apiVersion.isUrlElementRequired()) { return getFacebookEndpointUrls().getGraphEndpoint() + '/' + apiVersion.getUrlElement(); } else { return getFacebookEndpointUrls().getGraphEndpoint(); } }
/** * Returns the base endpoint URL for the Graph API's video upload functionality. * * @return The base endpoint URL for the Graph API's video upload functionality. * @since 1.6.5 */ protected String getFacebookGraphVideoEndpointUrl() { if (apiVersion.isUrlElementRequired()) { return getFacebookEndpointUrls().getGraphVideoEndpoint() + '/' + apiVersion.getUrlElement(); } else { return getFacebookEndpointUrls().getGraphVideoEndpoint(); } }
@Override public String getLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, Parameter... parameters) { verifyParameterPresence("appId", appId); verifyParameterPresence("redirectUri", redirectUri); verifyParameterPresence("scope", scope); String dialogUrl = getFacebookEndpointUrls().getFacebookEndpoint() + "/dialog/oauth"; List<Parameter> parameterList = new ArrayList<>(); parameterList.add(Parameter.with("client_id", appId)); parameterList.add(Parameter.with("redirect_uri", redirectUri)); parameterList.add(Parameter.with("scope", scope.toString())); // add optional parameters Collections.addAll(parameterList, parameters); return dialogUrl + "?" + toParameterString(false, parameterList.toArray(new Parameter[parameterList.size()])); }