/** * @see com.restfb.LegacyFacebookClient#execute(String, * Class, com.restfb.Parameter[]) */ @Override public <T> T execute(String method, Class<T> resultType, Parameter... parameters) { return execute(method, null, resultType, parameters); }
/** * @see com.restfb.LegacyFacebookClient#executeForList(String, * Class, com.restfb.Parameter[]) */ @Override public <T> List<T> executeForList(String method, Class<T> resultType, Parameter... parameters) { return executeForList(method, null, resultType, parameters); }
/** * @see com.restfb.LegacyFacebookClient#executeMultiquery(java.util.Map, * Class, com.restfb.Parameter[]) */ @Override public <T> T executeMultiquery(Map<String, String> queries, Class<T> resultType, Parameter... additionalParameters) { return executeMultiquery(queries, resultType, additionalParameters); }
/** * Creates a Facebook API client with the given <a * href="http://developers.facebook.com/docs/guides/upgrade#oauth">OAuth * access token</a>. * * @param accessToken An OAuth access token. * @param webRequestor The {@link WebRequestor} implementation to use for {@code POST}ing * to the API endpoint. * @param jsonMapper The {@link JsonMapper} implementation to use for mapping API * response JSON to Java objects. * @throws NullPointerException If any parameter is {@code null}. * @throws IllegalArgumentException If {@code accessToken} is a blank string. * @since 1.5 */ public DefaultLegacyFacebookClient(String accessToken, WebRequestor webRequestor, JsonMapper jsonMapper) { verifyParameterPresence("accessToken", accessToken); verifyParameterPresence("webRequestor", webRequestor); verifyParameterPresence("jsonMapper", jsonMapper); this.accessToken = accessToken.trim(); this.webRequestor = webRequestor; this.jsonMapper = jsonMapper; initializeIllegalParamNames(); }
verifyParameterLegality(parameters); String parametersAsString = toParameterString(method, sessionKey, parameters); webRequestor.executePost(usesAccessTokenAuthentication() ? getFacebookRestOauthEndpointUrl() : getFacebookRestEndpointUrl(), parametersAsString); } catch (Throwable t) { throw new FacebookNetworkException("Facebook POST failed", t); throwLegacyFacebookResponseStatusExceptionIfNecessary(json);
if (usesAccessTokenAuthentication()) { if (sessionKey != null) throw new IllegalArgumentException("If you're using the OAuth access token " sortedParameters.put(SESSION_KEY_PARAM_NAME, sessionKey); sortedParameters.put(SIG_PARAM_NAME, generateSignature(sortedParameters)); parameterStringBuilder.append(usesAccessTokenAuthentication() ? urlEncodedValueForParameterName(entry.getKey(), entry.getValue()) : urlEncode(entry.getValue()));
Parameter... additionalParameters) { List<Parameter> parameters = new ArrayList<Parameter>(); parameters.add(Parameter.with("queries", queriesToJson(queries))); new JsonArray(makeRequest("fql.multiquery", sessionKey, parameters.toArray(new Parameter[0])));
/** * @see com.restfb.LegacyFacebookClient#execute(String, * String, com.restfb.Parameter[]) */ @Override public void execute(String method, String sessionKey, Parameter... parameters) { makeRequest(method, sessionKey, parameters); }
/** * Given a sorted map of parameter names to values, calculate and return the * Facebook API signature as defined by * http://wiki.developers.facebook.com/index.php/Verifying_The_Signature. * * @param sortedParameters Parameter name/value mappings, sorted alphabetically. * @return The Facebook API signature which matches the given parameter map. */ protected String generateSignature(Map<String, String> sortedParameters) { StringBuilder parameterString = new StringBuilder(); for (Entry<String, String> entry : sortedParameters.entrySet()) { parameterString.append(entry.getKey()); parameterString.append("="); parameterString.append(entry.getValue()); } parameterString.append(secretKey); return generateMd5(parameterString.toString()); }
/** * Creates a Facebook API client with the given API key, secret key, * {@code webRequestor}, and {@code jsonMapper} (Legacy authentication). * * @param apiKey A Facebook API key. * @param secretKey A Facebook application secret key. * @param webRequestor The {@link WebRequestor} implementation to use for {@code POST}ing * to the API endpoint. * @param jsonMapper The {@link JsonMapper} implementation to use for mapping API * response JSON to Java objects. * @throws NullPointerException If any parameter is {@code null}. * @throws IllegalArgumentException If either {@code apiKey} or {@code secretKey} is a blank string. * @deprecated You should use * {@link #DefaultLegacyFacebookClient(String, WebRequestor, JsonMapper)} * instead. Facebook is moving to OAuth and will stop supporting * the old authentication scheme soon. */ @Deprecated public DefaultLegacyFacebookClient(String apiKey, String secretKey, WebRequestor webRequestor, JsonMapper jsonMapper) { verifyParameterPresence("apiKey", apiKey); verifyParameterPresence("secretKey", secretKey); verifyParameterPresence("webRequestor", webRequestor); verifyParameterPresence("jsonMapper", jsonMapper); this.apiKey = apiKey.trim(); this.secretKey = secretKey.trim(); this.webRequestor = webRequestor; this.jsonMapper = jsonMapper; initializeIllegalParamNames(); }
/** * @see com.restfb.LegacyFacebookClient#execute(String, * String, Class, com.restfb.Parameter[]) */ @Override public <T> T execute(String method, String sessionKey, Class<T> resultType, Parameter... parameters) { return jsonMapper.toJavaObject(makeRequest(method, sessionKey, parameters), resultType); }
/** * @see com.restfb.LegacyFacebookClient#executeForList(String, * String, Class, com.restfb.Parameter[]) */ @Override public <T> List<T> executeForList(String method, String sessionKey, Class<T> resultType, Parameter... parameters) { return jsonMapper.toJavaList(makeRequest(method, sessionKey, parameters), resultType); }
/** * @see com.restfb.LegacyFacebookClient#execute(String, * com.restfb.Parameter[]) */ @Override public void execute(String method, Parameter... parameters) { execute(method, (String) null, parameters); }