com.restfb
Class DefaultLegacyFacebookClient

java.lang.Object
  extended by com.restfb.DefaultLegacyFacebookClient
All Implemented Interfaces:
LegacyFacebookClient

public class DefaultLegacyFacebookClient
extends Object
implements LegacyFacebookClient

Default implementation of a Legacy Facebook API client.

Author:
Mark Allen

Constructor Summary
DefaultLegacyFacebookClient(String accessToken)
          Creates a Facebook API client with the given OAuth access token.
DefaultLegacyFacebookClient(String apiKey, String secretKey)
          Deprecated. You should use DefaultLegacyFacebookClient(String) instead. Facebook is moving to OAuth and will stop supporting the old authentication scheme soon.
DefaultLegacyFacebookClient(String apiKey, String secretKey, WebRequestor webRequestor, JsonMapper jsonMapper)
          Deprecated. You should use DefaultLegacyFacebookClient(String, WebRequestor, JsonMapper) instead. Facebook is moving to OAuth and will stop supporting the old authentication scheme soon.
DefaultLegacyFacebookClient(String accessToken, WebRequestor webRequestor, JsonMapper jsonMapper)
          Creates a Facebook API client with the given OAuth access token.
 
Method Summary
<T> T
execute(String method, Class<T> resultType, Parameter... parameters)
          Executes a Facebook API method with the given parameters, mapping the API response to a single instance of type resultType.
 void execute(String method, Parameter... parameters)
          Executes a Facebook API method with the given parameters, ignoring the response.
<T> T
execute(String method, String sessionKey, Class<T> resultType, Parameter... parameters)
          Executes a Facebook API method with the given parameters, mapping the API response to a single instance of type resultType.
 void execute(String method, String sessionKey, Parameter... parameters)
          Executes a Facebook API method with the given parameters, ignoring the response.
<T> List<T>
executeForList(String method, Class<T> resultType, Parameter... parameters)
          Executes a Facebook API method with the given parameters, mapping the API response to a List of instances of type resultType.
<T> List<T>
executeForList(String method, String sessionKey, Class<T> resultType, Parameter... parameters)
          Executes a Facebook API method with the given parameters, mapping the API response to a List of instances of type resultType.
<T> T
executeMultiquery(Map<String,String> queries, Class<T> resultType, Parameter... additionalParameters)
          Executes the fql.multiquery API call, mapping the API response to a single instance of type resultType.
<T> T
executeMultiquery(Map<String,String> queries, String sessionKey, Class<T> resultType, Parameter... additionalParameters)
          Executes the fql.multiquery API call, mapping the API response to a single instance of type resultType.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLegacyFacebookClient

public DefaultLegacyFacebookClient(String accessToken)
Creates a Facebook API client with the given OAuth access token.

Parameters:
accessToken - An OAuth access token.
Throws:
NullPointerException - If accessToken is null.
IllegalArgumentException - If accessToken is a blank string.
Since:
1.5

DefaultLegacyFacebookClient

@Deprecated
public DefaultLegacyFacebookClient(String apiKey,
                                              String secretKey)
Deprecated. You should use DefaultLegacyFacebookClient(String) instead. Facebook is moving to OAuth and will stop supporting the old authentication scheme soon.

Creates a Facebook API client with the given API key and secret key (Legacy authentication).

Parameters:
apiKey - A Facebook API key.
secretKey - A Facebook application secret key.
Throws:
NullPointerException - If either parameter is null.
IllegalArgumentException - If either parameter is a blank string.

DefaultLegacyFacebookClient

@Deprecated
public DefaultLegacyFacebookClient(String apiKey,
                                              String secretKey,
                                              WebRequestor webRequestor,
                                              JsonMapper jsonMapper)
Deprecated. You should use DefaultLegacyFacebookClient(String, WebRequestor, JsonMapper) instead. Facebook is moving to OAuth and will stop supporting the old authentication scheme soon.

Creates a Facebook API client with the given API key, secret key, webRequestor, and jsonMapper (Legacy authentication).

Parameters:
apiKey - A Facebook API key.
secretKey - A Facebook application secret key.
webRequestor - The WebRequestor implementation to use for POSTing to the API endpoint.
jsonMapper - The JsonMapper implementation to use for mapping API response JSON to Java objects.
Throws:
NullPointerException - If any parameter is null.
IllegalArgumentException - If either apiKey or secretKey is a blank string.

DefaultLegacyFacebookClient

public DefaultLegacyFacebookClient(String accessToken,
                                   WebRequestor webRequestor,
                                   JsonMapper jsonMapper)
Creates a Facebook API client with the given OAuth access token.

Parameters:
accessToken - An OAuth access token.
webRequestor - The WebRequestor implementation to use for POSTing to the API endpoint.
jsonMapper - The JsonMapper implementation to use for mapping API response JSON to Java objects.
Throws:
NullPointerException - If any parameter is null.
IllegalArgumentException - If accessToken is a blank string.
Since:
1.5
Method Detail

execute

public void execute(String method,
                    Parameter... parameters)
Description copied from interface: LegacyFacebookClient
Executes a Facebook API method with the given parameters, ignoring the response.

Specified by:
execute in interface LegacyFacebookClient
Parameters:
method - The Facebook API method to call, e.g. fql.query.
parameters - Parameters to include in the API call.
See Also:
LegacyFacebookClient.execute(java.lang.String, com.restfb.Parameter[])

execute

public void execute(String method,
                    String sessionKey,
                    Parameter... parameters)
Description copied from interface: LegacyFacebookClient
Executes a Facebook API method with the given parameters, ignoring the response.

Specified by:
execute in interface LegacyFacebookClient
Parameters:
method - The Facebook API method to call, e.g. fql.query.
sessionKey - A Facebook API session key if you're using the legacy API key/Secret key authentication scheme. Must be null if using OAuth access token authentication.
parameters - Parameters to include in the API call.
See Also:
LegacyFacebookClient.execute(java.lang.String, java.lang.String, com.restfb.Parameter[])

execute

public <T> T execute(String method,
                     Class<T> resultType,
                     Parameter... parameters)
Description copied from interface: LegacyFacebookClient
Executes a Facebook API method with the given parameters, mapping the API response to a single instance of type resultType.

Specified by:
execute in interface LegacyFacebookClient
Type Parameters:
T - Java type to map to.
Parameters:
method - The Facebook API method to call, e.g. fql.query.
resultType - Result type token.
parameters - Parameters to include in the API call.
Returns:
An instance of type resultType which contains API response data.
See Also:
LegacyFacebookClient.execute(java.lang.String, java.lang.Class, com.restfb.Parameter[])

execute

public <T> T execute(String method,
                     String sessionKey,
                     Class<T> resultType,
                     Parameter... parameters)
Description copied from interface: LegacyFacebookClient
Executes a Facebook API method with the given parameters, mapping the API response to a single instance of type resultType.

Specified by:
execute in interface LegacyFacebookClient
Type Parameters:
T - Java type to map to.
Parameters:
method - The Facebook API method to call, e.g. fql.query.
sessionKey - A Facebook API session key if you're using the legacy API key/Secret key authentication scheme. Must be null if using OAuth access token authentication.
resultType - Result type token.
parameters - Parameters to include in the API call.
Returns:
An instance of type resultType which contains API response data.
See Also:
LegacyFacebookClient.execute(java.lang.String, java.lang.String, java.lang.Class, com.restfb.Parameter[])

executeForList

public <T> List<T> executeForList(String method,
                                  Class<T> resultType,
                                  Parameter... parameters)
Description copied from interface: LegacyFacebookClient
Executes a Facebook API method with the given parameters, mapping the API response to a List of instances of type resultType.

Specified by:
executeForList in interface LegacyFacebookClient
Type Parameters:
T - Java type to map to.
Parameters:
method - The Facebook API method to call, e.g. fql.query.
resultType - Result type token.
parameters - Parameters to include in the API call.
Returns:
A List of instances of type resultType which contain API response data.
See Also:
LegacyFacebookClient.executeForList(java.lang.String, java.lang.Class, com.restfb.Parameter[])

executeForList

public <T> List<T> executeForList(String method,
                                  String sessionKey,
                                  Class<T> resultType,
                                  Parameter... parameters)
Description copied from interface: LegacyFacebookClient
Executes a Facebook API method with the given parameters, mapping the API response to a List of instances of type resultType.

Specified by:
executeForList in interface LegacyFacebookClient
Type Parameters:
T - Java type to map to.
Parameters:
method - The Facebook API method to call, e.g. fql.query.
sessionKey - A Facebook API session key if you're using the legacy API key/Secret key authentication scheme. Must be null if using OAuth access token authentication.
resultType - Result type token.
parameters - Parameters to include in the API call.
Returns:
A List of instances of type resultType which contain API response data.
See Also:
LegacyFacebookClient.executeForList(java.lang.String, java.lang.String, java.lang.Class, com.restfb.Parameter[])

executeMultiquery

public <T> T executeMultiquery(Map<String,String> queries,
                               Class<T> resultType,
                               Parameter... additionalParameters)
Description copied from interface: LegacyFacebookClient
Executes the fql.multiquery API call, mapping the API response to a single instance of type resultType.

This method exists because the standard LegacyFacebookClient.execute(String, Parameter...) and LegacyFacebookClient.executeForList(String, Class, Parameter...) family of methods are not expressive enough to handle fql.multiquery in a non-verbose way.

Specified by:
executeMultiquery in interface LegacyFacebookClient
Type Parameters:
T - Java type to map to.
Parameters:
queries - A mapping of query names to queries. This is marshaled to JSON and sent over the wire to the Facebook API endpoint as the queries parameter.
resultType - Result type token.
additionalParameters - Additional parameters to include in the API call.
Returns:
An instance of type resultType which contains API response data.
See Also:
LegacyFacebookClient.executeMultiquery(java.util.Map, java.lang.Class, com.restfb.Parameter[])

executeMultiquery

public <T> T executeMultiquery(Map<String,String> queries,
                               String sessionKey,
                               Class<T> resultType,
                               Parameter... additionalParameters)
Description copied from interface: LegacyFacebookClient
Executes the fql.multiquery API call, mapping the API response to a single instance of type resultType.

This method exists because the standard LegacyFacebookClient.execute(String, Parameter...) and LegacyFacebookClient.executeForList(String, Class, Parameter...) family of methods are not expressive enough to handle fql.multiquery in a non-verbose way.

Specified by:
executeMultiquery in interface LegacyFacebookClient
Type Parameters:
T - Java type to map to.
Parameters:
queries - A mapping of query names to queries. This is marshaled to JSON and sent over the wire to the Facebook API endpoint as the queries parameter.
sessionKey - A Facebook API session key if you're using the legacy API key/Secret key authentication scheme. Must be null if using OAuth access token authentication.
resultType - Result type token.
additionalParameters - Additional parameters to include in the API call.
Returns:
An instance of type resultType which contains API response data.
See Also:
LegacyFacebookClient.executeMultiquery(java.util.Map, java.lang.String, java.lang.Class, com.restfb.Parameter[])


RestFB 1.6.8. Copyright © 2010-2011 Mark Allen. All Rights Reserved.