com.restfb
Interface FacebookClient

All Known Implementing Classes:
DefaultFacebookClient

public interface FacebookClient

Specifies how a Facebook Graph API client must operate.

Projects that need to access the old REST API should use LegacyFacebookClient instead. You might choose to do this because you have a legacy codebase or you need functionality that is not yet available in the Graph API.

If you'd like to...

Author:
Mark Allen

Method Summary
 boolean deleteObject(String object)
          Performs a Graph API delete operation on the given object.
<T> T
executeMultiquery(Map<String,String> queries, Class<T> objectType, Parameter... parameters)
          Executes an FQL multiquery, which allows you to batch multiple queries into a single request.
<T> List<T>
executeQuery(String query, Class<T> objectType, Parameter... parameters)
          Executes an FQL query.
<T> Connection<T>
fetchConnection(String connection, Class<T> connectionType, Parameter... parameters)
          Fetches a Graph API Connection type.
<T> T
fetchObject(String object, Class<T> objectType, Parameter... parameters)
          Fetches a single Graph API object.
<T> T
fetchObjects(List<String> ids, Class<T> objectType, Parameter... parameters)
          Fetches multiple Graph API objects in a single call.
<T> T
publish(String connection, Class<T> objectType, InputStream binaryAttachment, Parameter... parameters)
          Performs a Graph API publish operation on the given connection and include a file - a photo, for example - in the publish request.
<T> T
publish(String connection, Class<T> objectType, Parameter... parameters)
          Performs a Graph API publish operation on the given connection.
 

Method Detail

fetchObject

<T> T fetchObject(String object,
                  Class<T> objectType,
                  Parameter... parameters)
              throws FacebookException
Fetches a single Graph API object.

Type Parameters:
T - Java type to map to.
Parameters:
object - ID of the object to fetch, e.g. "me".
objectType - Object type token.
parameters - URL parameters to include in the API call (optional).
Returns:
An instance of type objectType which contains the requested object's data.
Throws:
FacebookException - If an error occurs while performing the API call.

fetchObjects

<T> T fetchObjects(List<String> ids,
                   Class<T> objectType,
                   Parameter... parameters)
               throws FacebookException
Fetches multiple Graph API objects in a single call.

You'll need to write your own container type (objectType) to hold the results. See http://restfb.com for an example of how to do this.

Type Parameters:
T - Java type to map to.
Parameters:
ids - IDs of the objects to fetch, e.g. "me", "arjun".
objectType - Object type token.
parameters - URL parameters to include in the API call (optional).
Returns:
An instance of type objectType which contains the requested objects' data.
Throws:
FacebookException - If an error occurs while performing the API call.

fetchConnection

<T> Connection<T> fetchConnection(String connection,
                                  Class<T> connectionType,
                                  Parameter... parameters)
                              throws FacebookException
Fetches a Graph API Connection type.

Type Parameters:
T - Java type to map to.
Parameters:
connection - The name of the connection, e.g. "me/feed".
connectionType - Connection type token.
parameters - URL parameters to include in the API call (optional).
Returns:
An instance of type connectionType which contains the requested Connection's data.
Throws:
FacebookException - If an error occurs while performing the API call.

executeQuery

<T> List<T> executeQuery(String query,
                         Class<T> objectType,
                         Parameter... parameters)
                     throws FacebookException
Executes an FQL query.

Type Parameters:
T - Java type to map to.
Parameters:
query - The FQL query to execute, e.g. "SELECT name FROM user WHERE uid=220439 or uid=7901103".
objectType - Resultset object type token.
parameters - URL parameters to include in the API call (optional).
Returns:
A list of instances of objectType which map to the query results.
Throws:
FacebookException - If an error occurs while performing the API call.

executeMultiquery

<T> T executeMultiquery(Map<String,String> queries,
                        Class<T> objectType,
                        Parameter... parameters)
                    throws FacebookException
Executes an FQL multiquery, which allows you to batch multiple queries into a single request.

You'll need to write your own container type (objectType) to hold the results. See http://restfb.com for an example of how to do this.

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.
objectType - Object type token.
parameters - URL parameters to include in the API call (optional).
Returns:
An instance of type objectType which contains the requested objects' data.
Throws:
FacebookException - If an error occurs while performing the API call.

publish

<T> T publish(String connection,
              Class<T> objectType,
              Parameter... parameters)
          throws FacebookException
Performs a Graph API publish operation on the given connection.

Type Parameters:
T - Java type to map to.
Parameters:
connection - The Connection to publish to.
objectType - Object type token.
parameters - URL parameters to include in the API call.
Returns:
An instance of type objectType which contains the Facebook response to your publish request.
Throws:
FacebookException - If an error occurs while performing the API call.

publish

<T> T publish(String connection,
              Class<T> objectType,
              InputStream binaryAttachment,
              Parameter... parameters)
          throws FacebookException
Performs a Graph API publish operation on the given connection and include a file - a photo, for example - in the publish request.

Type Parameters:
T - Java type to map to.
Parameters:
connection - The Connection to publish to.
objectType - Object type token.
binaryAttachment - The file to include in the publish request - a photo, for example.
parameters - URL parameters to include in the API call.
Returns:
An instance of type objectType which contains the Facebook response to your publish request.
Throws:
FacebookException - If an error occurs while performing the API call.

deleteObject

boolean deleteObject(String object)
                     throws FacebookException
Performs a Graph API delete operation on the given object.

Parameters:
object - The ID of the object to delete.
Returns:
true if Facebook indicated that the object was successfully deleted, false otherwise.
Throws:
FacebookException - If an error occurred while attempting to delete the object.


RestFB version 1.5.3. Copyright © 2010 Mark Allen. All Rights Reserved.