Android SDK Version
  • java.lang.Object
    • com.facebook.GraphRequest

public class GraphRequest
extends java.lang.Object
A single request to be sent to the Facebook Platform through the Graph API. The Request class provides functionality relating to serializing and deserializing requests and responses, making calls in batches (with a single round-trip to the service) and making calls asynchronously.
The particular service endpoint that a request targets is determined by a graph path (see the setGraphPath method).
A Request can be executed either anonymously or representing an authenticated user. In the former case, no AccessToken needs to be specified, while in the latter, an AccessToken must be provided. If requests are executed in a batch, a Facebook application ID must be associated with the batch, either by setting the application ID in the AndroidManifest.xml or via FacebookSdk or by calling the setDefaultBatchApplicationId method.
After completion of a request, the AccessToken, if not null and taken from AccessTokenManager, will be checked to determine if its Facebook access token needs to be extended; if so, a request to extend it will be issued in the background.
Nested Class Summary
Modifier and TypeClass and Description
static interface GraphRequest.Callback
Specifies the interface that consumers of the Request class can implement in order to be notified when a particular request completes, either successfully or with an error.
static interface GraphRequest.GraphJSONArrayCallback
Callback for requests that result in an array of JSONObjects.
static interface GraphRequest.GraphJSONObjectCallback
Callback for requests that result in a JSONObject.
static interface GraphRequest.OnProgressCallback
Specifies the interface that consumers of the Request class can implement in order to be notified when a progress is made on a particular request.
static class GraphRequest.ParcelableResourceWithMimeType<RESOURCE extends Parcelable>
Used during serialization for the graph request.
Field Summary
Modifier and TypeField and Description
static java.lang.StringACCESS_TOKEN_PARAM 
static java.lang.StringFIELDS_PARAM 
static intMAXIMUM_BATCH_SIZE
The maximum number of requests that can be submitted in a single batch.
static java.lang.StringTAG 
Constructor Summary
Constructor and Description
GraphRequest()
Constructs a request without an access token, graph path, or any other parameters.
GraphRequest(AccessToken accessToken, java.lang.String graphPath)
Constructs a request with an access token to retrieve a particular graph path.
GraphRequest(AccessToken accessToken, java.lang.String graphPath, Bundle parameters, HttpMethod httpMethod)
Constructs a request with a specific AccessToken, graph path, parameters, and HTTP method.
GraphRequest(AccessToken accessToken, java.lang.String graphPath, Bundle parameters, HttpMethod httpMethod, GraphRequest.Callback callback)
Constructs a request with a specific access token, graph path, parameters, and HTTP method.
GraphRequest(AccessToken accessToken, java.lang.String graphPath, Bundle parameters, HttpMethod httpMethod, GraphRequest.Callback callback, java.lang.String version)
Constructs a request with a specific access token, graph path, parameters, and HTTP method.
Method Summary
Modifier and TypeMethod and Description
GraphResponseexecuteAndWait()
Executes this request on the current thread and blocks while waiting for the response.
static GraphResponseexecuteAndWait(GraphRequest request)
Executes a single request on the current thread and blocks while waiting for the response.
GraphRequestAsyncTaskexecuteAsync()
Executes the request asynchronously.
static java.util.List<GraphResponse>executeBatchAndWait(java.util.Collection<GraphRequest> requests)
Executes requests as a single batch on the current thread and blocks while waiting for the responses.
static java.util.List<GraphResponse>executeBatchAndWait(GraphRequest... requests)
Executes requests on the current thread as a single batch and blocks while waiting for the response.
static java.util.List<GraphResponse>executeBatchAndWait(GraphRequestBatch requests)
Executes requests on the current thread as a single batch and blocks while waiting for the responses.
static GraphRequestAsyncTaskexecuteBatchAsync(java.util.Collection<GraphRequest> requests)
Executes requests as a single batch asynchronously.
static GraphRequestAsyncTaskexecuteBatchAsync(GraphRequest... requests)
Executes requests as a single batch asynchronously.
static GraphRequestAsyncTaskexecuteBatchAsync(GraphRequestBatch requests)
Executes requests as a single batch asynchronously.
static java.util.List<GraphResponse>executeConnectionAndWait(java.net.HttpURLConnection connection, java.util.Collection<GraphRequest> requests)
Executes requests that have already been serialized into an HttpURLConnection.
static java.util.List<GraphResponse>executeConnectionAndWait(java.net.HttpURLConnection connection, GraphRequestBatch requests)
Executes requests that have already been serialized into an HttpURLConnection.
static GraphRequestAsyncTaskexecuteConnectionAsync(Handler callbackHandler, java.net.HttpURLConnection connection, GraphRequestBatch requests)
Asynchronously executes requests that have already been serialized into an HttpURLConnection.
static GraphRequestAsyncTaskexecuteConnectionAsync(java.net.HttpURLConnection connection, GraphRequestBatch requests)
Asynchronously executes requests that have already been serialized into an HttpURLConnection.
AccessTokengetAccessToken()
Returns the access token associated with this request.
java.lang.StringgetBatchEntryDependsOn()
Returns the name of the request that this request entry explicitly depends on in a batched request.
java.lang.StringgetBatchEntryName()
Returns the name of this requests entry in a batched request.
booleangetBatchEntryOmitResultOnSuccess()
Returns whether or not this batch entry will return a response if it is successful.
GraphRequest.CallbackgetCallback()
Returns the callback which will be called when the request finishes.
static java.lang.StringgetDefaultBatchApplicationId()
Gets the default Facebook application ID that will be used to submit batched requests.
JSONObjectgetGraphObject()
Returns the GraphObject, if any, associated with this request.
java.lang.StringgetGraphPath()
Returns the graph path of this request, if any.
HttpMethodgetHttpMethod()
Returns the HttpMethod to use for this request.
BundlegetParameters()
Returns the parameters for this request.
java.lang.ObjectgetTag()
Gets the tag on the request; this is an application-defined object that can be used to distinguish between different requests.
java.lang.StringgetVersion()
Returns the version of the API that this request will use.
static GraphRequestnewCustomAudienceThirdPartyIdRequest(AccessToken accessToken, Context context, GraphRequest.Callback callback)
Creates a new Request configured to retrieve an App User ID for the app's Facebook user.
static GraphRequestnewCustomAudienceThirdPartyIdRequest(AccessToken accessToken, Context context, java.lang.String applicationId, GraphRequest.Callback callback)
Creates a new Request configured to retrieve an App User ID for the app's Facebook user.
static GraphRequestnewDeleteObjectRequest(AccessToken accessToken, java.lang.String id, GraphRequest.Callback callback)
Creates a new Request configured to delete a resource through the Graph API.
static GraphRequestnewGraphPathRequest(AccessToken accessToken, java.lang.String graphPath, GraphRequest.Callback callback)
Creates a new Request configured to retrieve a particular graph path.
static GraphRequestnewMeRequest(AccessToken accessToken, GraphRequest.GraphJSONObjectCallback callback)
Creates a new Request configured to retrieve a user's own profile.
static GraphRequestnewMyFriendsRequest(AccessToken accessToken, GraphRequest.GraphJSONArrayCallback callback)
Creates a new Request configured to retrieve a user's friend list.
static GraphRequestnewPlacesSearchRequest(AccessToken accessToken, Location location, int radiusInMeters, int resultsLimit, java.lang.String searchText, GraphRequest.GraphJSONArrayCallback callback)
Creates a new Request that is configured to perform a search for places near a specified location via the Graph API.
static GraphRequestnewPostRequest(AccessToken accessToken, java.lang.String graphPath, JSONObject graphObject, GraphRequest.Callback callback)
Creates a new Request configured to post a GraphObject to a particular graph path, to either create or update the object at that path.
static GraphRequestnewUploadPhotoRequest(AccessToken accessToken, java.lang.String graphPath, Bitmap image, java.lang.String caption, Bundle params, GraphRequest.Callback callback)
Creates a new Request configured to upload a photo to the specified graph path.
static GraphRequestnewUploadPhotoRequest(AccessToken accessToken, java.lang.String graphPath, java.io.File file, java.lang.String caption, Bundle params, GraphRequest.Callback callback)
Creates a new Request configured to upload a photo to the specified graph path.
static GraphRequestnewUploadPhotoRequest(AccessToken accessToken, java.lang.String graphPath, Uri photoUri, java.lang.String caption, Bundle params, GraphRequest.Callback callback)
Creates a new Request configured to upload a photo to the specified graph path.
voidsetAccessToken(AccessToken accessToken)
Sets the access token to use for this request.
voidsetBatchEntryDependsOn(java.lang.String batchEntryDependsOn)
Sets the name of the request entry that this request explicitly depends on in a batched request.
voidsetBatchEntryName(java.lang.String batchEntryName)
Sets the name of this request's entry in a batched request.
voidsetBatchEntryOmitResultOnSuccess(boolean batchEntryOmitResultOnSuccess)
Sets whether or not this batch entry will return a response if it is successful.
voidsetCallback(GraphRequest.Callback callback)
Sets the callback which will be called when the request finishes.
static voidsetDefaultBatchApplicationId(java.lang.String applicationId)
Sets the default application ID that will be used to submit batched requests if none of those requests specifies an access token.
voidsetGraphObject(JSONObject graphObject)
Sets the GraphObject associated with this request.
voidsetGraphPath(java.lang.String graphPath)
Sets the graph path of this request.
voidsetHttpMethod(HttpMethod httpMethod)
Sets the HttpMethod to use for this request.
voidsetParameters(Bundle parameters)
Sets the parameters for this request.
voidsetSkipClientToken(boolean skipClientToken)
This is an internal function that is not meant to be used by developers.
voidsetTag(java.lang.Object tag)
Sets the tag on the request; this is an application-defined object that can be used to distinguish between different requests.
voidsetVersion(java.lang.String version)
Set the version to use for this request.
static java.net.HttpURLConnectiontoHttpConnection(java.util.Collection<GraphRequest> requests)
Serializes one or more requests but does not execute them.
static java.net.HttpURLConnectiontoHttpConnection(GraphRequest... requests)
Serializes one or more requests but does not execute them.
static java.net.HttpURLConnectiontoHttpConnection(GraphRequestBatch requests)
Serializes one or more requests but does not execute them.
java.lang.StringtoString()
Returns a string representation of this Request, useful for debugging.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail

MAXIMUM_BATCH_SIZE

public static final int MAXIMUM_BATCH_SIZE
The maximum number of requests that can be submitted in a single batch. This limit is enforced on the service side by the Facebook platform, not by the Request class.

TAG

public static final java.lang.String TAG

ACCESS_TOKEN_PARAM

public static final java.lang.String ACCESS_TOKEN_PARAM

FIELDS_PARAM

public static final java.lang.String FIELDS_PARAM
Constructor Detail

GraphRequest

public GraphRequest()
Constructs a request without an access token, graph path, or any other parameters.

GraphRequest

public GraphRequest(AccessToken accessToken,
                    java.lang.String graphPath)
Constructs a request with an access token to retrieve a particular graph path. An access token need not be provided, in which case the request is sent without an access token and thus is not executed in the context of any particular user. Only certain graph requests can be expected to succeed in this case.
Parameters:
accessToken - the access token to use, or null
graphPath - the graph path to retrieve

GraphRequest

public GraphRequest(AccessToken accessToken,
                    java.lang.String graphPath,
                    Bundle parameters,
                    HttpMethod httpMethod)
Constructs a request with a specific AccessToken, graph path, parameters, and HTTP method. An access token need not be provided, in which case the request is sent without an access token and thus is not executed in the context of any particular user. Only certain graph requests can be expected to succeed in this case.
Depending on the httpMethod parameter, the object at the graph path may be retrieved, created, or deleted.
Parameters:
accessToken - the access token to use, or null
graphPath - the graph path to retrieve, create, or delete
parameters - additional parameters to pass along with the Graph API request; parameters must be Strings, Numbers, Bitmaps, Dates, or Byte arrays.
httpMethod - the HttpMethod to use for the request, or null for default (HttpMethod.GET)

GraphRequest

public GraphRequest(AccessToken accessToken,
                    java.lang.String graphPath,
                    Bundle parameters,
                    HttpMethod httpMethod,
                    GraphRequest.Callback callback)
Constructs a request with a specific access token, graph path, parameters, and HTTP method. An access token need not be provided, in which case the request is sent without an access token and thus is not executed in the context of any particular user. Only certain graph requests can be expected to succeed in this case.
Depending on the httpMethod parameter, the object at the graph path may be retrieved, created, or deleted.
Parameters:
accessToken - the access token to use, or null
graphPath - the graph path to retrieve, create, or delete
parameters - additional parameters to pass along with the Graph API request; parameters must be Strings, Numbers, Bitmaps, Dates, or Byte arrays.
httpMethod - the HttpMethod to use for the request, or null for default (HttpMethod.GET)
callback - a callback that will be called when the request is completed to handle success or error conditions

GraphRequest

public GraphRequest(AccessToken accessToken,
                    java.lang.String graphPath,
                    Bundle parameters,
                    HttpMethod httpMethod,
                    GraphRequest.Callback callback,
                    java.lang.String version)
Constructs a request with a specific access token, graph path, parameters, and HTTP method. An access token need not be provided, in which case the request is sent without an access token and thus is not executed in the context of any particular user. Only certain graph requests can be expected to succeed in this case.
Depending on the httpMethod parameter, the object at the graph path may be retrieved, created, or deleted.
Parameters:
accessToken - the access token to use, or null
graphPath - the graph path to retrieve, create, or delete
parameters - additional parameters to pass along with the Graph API request; parameters must be Strings, Numbers, Bitmaps, Dates, or Byte arrays.
httpMethod - the HttpMethod to use for the request, or null for default (HttpMethod.GET)
callback - a callback that will be called when the request is completed to handle success or error conditions
version - the version of the Graph API
Method Detail

newDeleteObjectRequest

public static GraphRequest newDeleteObjectRequest(AccessToken accessToken,
                                                  java.lang.String id,
                                                  GraphRequest.Callback callback)
Creates a new Request configured to delete a resource through the Graph API.
Parameters:
accessToken - the access token to use, or null
id - the id of the object to delete
callback - a callback that will be called when the request is completed to handle success or error conditions
Returns:
a Request that is ready to execute

newMeRequest

public static GraphRequest newMeRequest(AccessToken accessToken,
                                        GraphRequest.GraphJSONObjectCallback callback)
Creates a new Request configured to retrieve a user's own profile.
Parameters:
accessToken - the access token to use, or null
callback - a callback that will be called when the request is completed to handle success or error conditions
Returns:
a Request that is ready to execute

newPostRequest

public static GraphRequest newPostRequest(AccessToken accessToken,
                                          java.lang.String graphPath,
                                          JSONObject graphObject,
                                          GraphRequest.Callback callback)
Creates a new Request configured to post a GraphObject to a particular graph path, to either create or update the object at that path.
Parameters:
accessToken - the access token to use, or null
graphPath - the graph path to retrieve, create, or delete
graphObject - the graph object to create or update
callback - a callback that will be called when the request is completed to handle success or error conditions
Returns:
a Request that is ready to execute

newMyFriendsRequest

public static GraphRequest newMyFriendsRequest(AccessToken accessToken,
                                               GraphRequest.GraphJSONArrayCallback callback)
Creates a new Request configured to retrieve a user's friend list.
Parameters:
accessToken - the access token to use, or null
callback - a callback that will be called when the request is completed to handle success or error conditions
Returns:
a Request that is ready to execute

newGraphPathRequest

public static GraphRequest newGraphPathRequest(AccessToken accessToken,
                                               java.lang.String graphPath,
                                               GraphRequest.Callback callback)
Creates a new Request configured to retrieve a particular graph path.
Parameters:
accessToken - the access token to use, or null
graphPath - the graph path to retrieve
callback - a callback that will be called when the request is completed to handle success or error conditions
Returns:
a Request that is ready to execute

newPlacesSearchRequest

public static GraphRequest newPlacesSearchRequest(AccessToken accessToken,
                                                  Location location,
                                                  int radiusInMeters,
                                                  int resultsLimit,
                                                  java.lang.String searchText,
                                                  GraphRequest.GraphJSONArrayCallback callback)
Creates a new Request that is configured to perform a search for places near a specified location via the Graph API. At least one of location or searchText must be specified.
Parameters:
accessToken - the access token to use, or null
location - the location around which to search; only the latitude and longitude components of the location are meaningful
radiusInMeters - the radius around the location to search, specified in meters; this is ignored if no location is specified
resultsLimit - the maximum number of results to return
searchText - optional text to search for as part of the name or type of an object
callback - a callback that will be called when the request is completed to handle success or error conditions
Returns:
a Request that is ready to execute
Throws:
FacebookException - If neither location nor searchText is specified

newUploadPhotoRequest

public static GraphRequest newUploadPhotoRequest(AccessToken accessToken,
                                                 java.lang.String graphPath,
                                                 Bitmap image,
                                                 java.lang.String caption,
                                                 Bundle params,
                                                 GraphRequest.Callback callback)
Creates a new Request configured to upload a photo to the specified graph path.
Parameters:
accessToken - the access token to use, or null
graphPath - the graph path to use, defaults to me/photos
image - the bitmap image to upload
caption - the user generated caption for the photo, can be null
params - the parameters, can be null
callback - a callback that will be called when the request is completed to handle success or error conditions, can be null
Returns:
a Request that is ready to execute

newUploadPhotoRequest

public static GraphRequest newUploadPhotoRequest(AccessToken accessToken,
                                                 java.lang.String graphPath,
                                                 java.io.File file,
                                                 java.lang.String caption,
                                                 Bundle params,
                                                 GraphRequest.Callback callback)
                                          throws java.io.FileNotFoundException
Creates a new Request configured to upload a photo to the specified graph path. The photo will be read from the specified file.
Parameters:
accessToken - the access token to use, or null
graphPath - the graph path to use, defaults to me/photos
file - the file containing the photo to upload
caption - the user generated caption for the photo, can be null
params - the parameters, can be null
callback - a callback that will be called when the request is completed to handle success or error conditions, can be null
Returns:
a Request that is ready to execute
Throws:
java.io.FileNotFoundException - if the file doesn't exist

newUploadPhotoRequest

public static GraphRequest newUploadPhotoRequest(AccessToken accessToken,
                                                 java.lang.String graphPath,
                                                 Uri photoUri,
                                                 java.lang.String caption,
                                                 Bundle params,
                                                 GraphRequest.Callback callback)
                                          throws java.io.FileNotFoundException
Creates a new Request configured to upload a photo to the specified graph path. The photo will be read from the specified Uri.
Parameters:
accessToken - the access token to use, or null
graphPath - the graph path to use, defaults to me/photos
photoUri - the file:// or content:// Uri to the photo on device
caption - the user generated caption for the photo, can be null
params - the parameters, can be null
callback - a callback that will be called when the request is completed to handle success or error conditions, can be null
Returns:
a Request that is ready to execute
Throws:
java.io.FileNotFoundException - if the Uri does not exist

newCustomAudienceThirdPartyIdRequest

public static GraphRequest newCustomAudienceThirdPartyIdRequest(AccessToken accessToken,
                                                                Context context,
                                                                java.lang.String applicationId,
                                                                GraphRequest.Callback callback)
Creates a new Request configured to retrieve an App User ID for the app's Facebook user. Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with, and then use the resultant Custom Audience to target ads.
The GraphObject in the response will include a "custom_audience_third_party_id" property, with the value being the ID retrieved. This ID is an encrypted encoding of the Facebook user's ID and the invoking Facebook app ID. Multiple calls with the same user will return different IDs, thus these IDs cannot be used to correlate behavior across devices or applications, and are only meaningful when sent back to Facebook for creating Custom Audiences.
The ID retrieved represents the Facebook user identified in the following way: if the specified access token (or active access token if `null`) is valid, the ID will represent the user associated with the active access token; otherwise the ID will represent the user logged into the native Facebook app on the device. A `null` ID will be provided into the callback if a) there is no native Facebook app, b) no one is logged into it, or c) the app has previously called FacebookSdk#setLimitEventAndDataUsage(android.content.Context, boolean) ;} with `true` for this user. You must call this method from a background thread for it to work properly.
Parameters:
accessToken - the access token to issue the Request on, or null If there is no logged-in Facebook user, null is the expected choice.
context - the Application context from which the app ID will be pulled, and from which the 'attribution ID' for the Facebook user is determined. If there has been no app ID set, an exception will be thrown.
applicationId - explicitly specified Facebook App ID. If null, the application ID from the access token will be used, if any; if not, the application ID from metadata will be used.
callback - a callback that will be called when the request is completed to handle success or error conditions. The GraphObject in the Response will contain a "custom_audience_third_party_id" property that represents the user as described above.
Returns:
a Request that is ready to execute

newCustomAudienceThirdPartyIdRequest

public static GraphRequest newCustomAudienceThirdPartyIdRequest(AccessToken accessToken,
                                                                Context context,
                                                                GraphRequest.Callback callback)
Creates a new Request configured to retrieve an App User ID for the app's Facebook user. Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with, and then use the resultant Custom Audience to target ads.
The GraphObject in the response will include a "custom_audience_third_party_id" property, with the value being the ID retrieved. This ID is an encrypted encoding of the Facebook user's ID and the invoking Facebook app ID. Multiple calls with the same user will return different IDs, thus these IDs cannot be used to correlate behavior across devices or applications, and are only meaningful when sent back to Facebook for creating Custom Audiences.
The ID retrieved represents the Facebook user identified in the following way: if the specified access token (or active access token if `null`) is valid, the ID will represent the user associated with the active access token; otherwise the ID will represent the user logged into the native Facebook app on the device. A `null` ID will be provided into the callback if a) there is no native Facebook app, b) no one is logged into it, or c) the app has previously called FacebookSdk#setLimitEventAndDataUsage(android.content.Context, boolean) with `true` for this user. You must call this method from a background thread for it to work properly.
Parameters:
accessToken - the access token to issue the Request on, or null If there is no logged-in Facebook user, null is the expected choice.
context - the Application context from which the app ID will be pulled, and from which the 'attribution ID' for the Facebook user is determined. If there has been no app ID set, an exception will be thrown.
callback - a callback that will be called when the request is completed to handle success or error conditions. The GraphObject in the Response will contain a "custom_audience_third_party_id" property that represents the user as described above.
Returns:
a Request that is ready to execute

getGraphObject

public final JSONObject getGraphObject()
Returns the GraphObject, if any, associated with this request.
Returns:
the GraphObject associated with this request, or null if there is none

setGraphObject

public final void setGraphObject(JSONObject graphObject)
Sets the GraphObject associated with this request. This is meaningful only for POST requests.
Parameters:
graphObject - the GraphObject to upload along with this request

getGraphPath

public final java.lang.String getGraphPath()
Returns the graph path of this request, if any.
Returns:
the graph path of this request, or null if there is none

setGraphPath

public final void setGraphPath(java.lang.String graphPath)
Sets the graph path of this request.
Parameters:
graphPath - the graph path for this request

getHttpMethod

public final HttpMethod getHttpMethod()
Returns the HttpMethod to use for this request.
Returns:
the HttpMethod

setHttpMethod

public final void setHttpMethod(HttpMethod httpMethod)
Sets the HttpMethod to use for this request.
Parameters:
httpMethod - the HttpMethod, or null for the default (HttpMethod.GET).

getVersion

public final java.lang.String getVersion()
Returns the version of the API that this request will use. By default this is the current API at the time the SDK is released.
Returns:
the version that this request will use

setVersion

public final void setVersion(java.lang.String version)
Set the version to use for this request. By default the version will be the current API at the time the SDK is released. Only use this if you need to explicitly override.
Parameters:
version - The version to use. Should look like "v2.0"

setSkipClientToken

public final void setSkipClientToken(boolean skipClientToken)
This is an internal function that is not meant to be used by developers.

getParameters

public final Bundle getParameters()
Returns the parameters for this request.
Returns:
the parameters

setParameters

public final void setParameters(Bundle parameters)
Sets the parameters for this request.
Parameters:
parameters - the parameters

getAccessToken

public final AccessToken getAccessToken()
Returns the access token associated with this request.
Returns:
the access token associated with this request, or null if none has been specified

setAccessToken

public final void setAccessToken(AccessToken accessToken)
Sets the access token to use for this request.
Parameters:
accessToken - the access token to use for this request

getBatchEntryName

public final java.lang.String getBatchEntryName()
Returns the name of this requests entry in a batched request.
Returns:
the name of this requests batch entry, or null if none has been specified

setBatchEntryName

public final void setBatchEntryName(java.lang.String batchEntryName)
Sets the name of this request's entry in a batched request. This value is only used if this request is submitted as part of a batched request. It can be used to specified dependencies between requests. See Batch Requests in the Graph API documentation for more details.
Parameters:
batchEntryName - the name of this requests entry in a batched request, which must be unique within a particular batch of requests

getBatchEntryDependsOn

public final java.lang.String getBatchEntryDependsOn()
Returns the name of the request that this request entry explicitly depends on in a batched request.
Returns:
the name of this requests dependency, or null if none has been specified

setBatchEntryDependsOn

public final void setBatchEntryDependsOn(java.lang.String batchEntryDependsOn)
Sets the name of the request entry that this request explicitly depends on in a batched request. This value is only used if this request is submitted as part of a batched request. It can be used to specified dependencies between requests. See Batch Requests in the Graph API documentation for more details.
Parameters:
batchEntryDependsOn - the name of the request entry that this entry depends on in a batched request

getBatchEntryOmitResultOnSuccess

public final boolean getBatchEntryOmitResultOnSuccess()
Returns whether or not this batch entry will return a response if it is successful. Only applies if another request entry in the batch specifies this entry as a dependency.
Returns:
the name of this requests dependency, or null if none has been specified

setBatchEntryOmitResultOnSuccess

public final void setBatchEntryOmitResultOnSuccess(boolean batchEntryOmitResultOnSuccess)
Sets whether or not this batch entry will return a response if it is successful. Only applies if another request entry in the batch specifies this entry as a dependency. See Batch Requests in the Graph API documentation for more details.
Parameters:
batchEntryOmitResultOnSuccess - the name of the request entry that this entry depends on in a batched request

getDefaultBatchApplicationId

public static final java.lang.String getDefaultBatchApplicationId()
Gets the default Facebook application ID that will be used to submit batched requests. Batched requests require an application ID, so either at least one request in a batch must provide an access token or the application ID must be specified explicitly.
Returns:
the Facebook application ID to use for batched requests if none can be determined

setDefaultBatchApplicationId

public static final void setDefaultBatchApplicationId(java.lang.String applicationId)
Sets the default application ID that will be used to submit batched requests if none of those requests specifies an access token. Batched requests require an application ID, so either at least one request in a batch must specify an access token or the application ID must be specified explicitly.
Parameters:
applicationId - the Facebook application ID to use for batched requests if none can be determined

getCallback

public final GraphRequest.Callback getCallback()
Returns the callback which will be called when the request finishes.
Returns:
the callback

setCallback

public final void setCallback(GraphRequest.Callback callback)
Sets the callback which will be called when the request finishes.
Parameters:
callback - the callback

setTag

public final void setTag(java.lang.Object tag)
Sets the tag on the request; this is an application-defined object that can be used to distinguish between different requests. Its value has no effect on the execution of the request.
Parameters:
tag - an object to serve as a tag, or null

getTag

public final java.lang.Object getTag()
Gets the tag on the request; this is an application-defined object that can be used to distinguish between different requests. Its value has no effect on the execution of the request.
Returns:
an object that serves as a tag, or null

executeAndWait

public final GraphResponse executeAndWait()
Executes this request on the current thread and blocks while waiting for the response.
This should only be called if you have transitioned off the UI thread.
Returns:
the Response object representing the results of the request
Throws:
FacebookException - If there was an error in the protocol used to communicate with the service
java.lang.IllegalArgumentException

executeAsync

public final GraphRequestAsyncTask executeAsync()
Executes the request asynchronously. This function will return immediately, and the request will be processed on a separate thread. In order to process result of a request, or determine whether a request succeeded or failed, a callback must be specified (see the setCallback method).
This should only be called from the UI thread.
Returns:
a RequestAsyncTask that is executing the request
Throws:
java.lang.IllegalArgumentException

toHttpConnection

public static java.net.HttpURLConnection toHttpConnection(GraphRequest... requests)
Serializes one or more requests but does not execute them. The resulting HttpURLConnection can be executed explicitly by the caller.
Parameters:
requests - one or more Requests to serialize
Returns:
an HttpURLConnection which is ready to execute
Throws:
FacebookException - If any of the requests in the batch are badly constructed or if there are problems contacting the service
java.lang.IllegalArgumentException - if the passed in array is zero-length
java.lang.NullPointerException - if the passed in array or any of its contents are null

toHttpConnection

public static java.net.HttpURLConnection toHttpConnection(java.util.Collection<GraphRequest> requests)
Serializes one or more requests but does not execute them. The resulting HttpURLConnection can be executed explicitly by the caller.
Parameters:
requests - one or more Requests to serialize
Returns:
an HttpURLConnection which is ready to execute
Throws:
FacebookException - If any of the requests in the batch are badly constructed or if there are problems contacting the service
java.lang.IllegalArgumentException - if the passed in collection is empty
java.lang.NullPointerException - if the passed in collection or any of its contents are null

toHttpConnection

public static java.net.HttpURLConnection toHttpConnection(GraphRequestBatch requests)
Serializes one or more requests but does not execute them. The resulting HttpURLConnection can be executed explicitly by the caller.
Parameters:
requests - a RequestBatch to serialize
Returns:
an HttpURLConnection which is ready to execute
Throws:
FacebookException - If any of the requests in the batch are badly constructed or if there are problems contacting the service
java.lang.IllegalArgumentException

executeAndWait

public static GraphResponse executeAndWait(GraphRequest request)
Executes a single request on the current thread and blocks while waiting for the response.
This should only be used if you have transitioned off the UI thread.
Parameters:
request - the Request to execute
Returns:
the Response object representing the results of the request
Throws:
FacebookException - If there was an error in the protocol used to communicate with the service

executeBatchAndWait

public static java.util.List<GraphResponse> executeBatchAndWait(GraphRequest... requests)
Executes requests on the current thread as a single batch and blocks while waiting for the response.
This should only be used if you have transitioned off the UI thread.
Parameters:
requests - the Requests to execute
Returns:
a list of Response objects representing the results of the requests; responses are returned in the same order as the requests were specified.
Throws:
java.lang.NullPointerException - In case of a null request
FacebookException - If there was an error in the protocol used to communicate with the service

executeBatchAndWait

public static java.util.List<GraphResponse> executeBatchAndWait(java.util.Collection<GraphRequest> requests)
Executes requests as a single batch on the current thread and blocks while waiting for the responses.
This should only be used if you have transitioned off the UI thread.
Parameters:
requests - the Requests to execute
Returns:
a list of Response objects representing the results of the requests; responses are returned in the same order as the requests were specified.
Throws:
FacebookException - If there was an error in the protocol used to communicate with the service

executeBatchAndWait

public static java.util.List<GraphResponse> executeBatchAndWait(GraphRequestBatch requests)
Executes requests on the current thread as a single batch and blocks while waiting for the responses.
This should only be used if you have transitioned off the UI thread.
Parameters:
requests - the batch of Requests to execute
Returns:
a list of Response objects representing the results of the requests; responses are returned in the same order as the requests were specified.
Throws:
FacebookException - If there was an error in the protocol used to communicate with the service
java.lang.IllegalArgumentException - if the passed in RequestBatch is empty
java.lang.NullPointerException - if the passed in RequestBatch or any of its contents are null

executeBatchAsync

public static GraphRequestAsyncTask executeBatchAsync(GraphRequest... requests)
Executes requests as a single batch asynchronously. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the setCallback method).
This should only be called from the UI thread.
Parameters:
requests - the Requests to execute
Returns:
a RequestAsyncTask that is executing the request
Throws:
java.lang.NullPointerException - If a null request is passed in

executeBatchAsync

public static GraphRequestAsyncTask executeBatchAsync(java.util.Collection<GraphRequest> requests)
Executes requests as a single batch asynchronously. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the setCallback method).
This should only be called from the UI thread.
Parameters:
requests - the Requests to execute
Returns:
a RequestAsyncTask that is executing the request
Throws:
java.lang.IllegalArgumentException - if the passed in collection is empty
java.lang.NullPointerException - if the passed in collection or any of its contents are null

executeBatchAsync

public static GraphRequestAsyncTask executeBatchAsync(GraphRequestBatch requests)
Executes requests as a single batch asynchronously. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the setCallback method).
This should only be called from the UI thread.
Parameters:
requests - the RequestBatch to execute
Returns:
a RequestAsyncTask that is executing the request
Throws:
java.lang.IllegalArgumentException - if the passed in RequestBatch is empty
java.lang.NullPointerException - if the passed in RequestBatch or any of its contents are null

executeConnectionAndWait

public static java.util.List<GraphResponse> executeConnectionAndWait(java.net.HttpURLConnection connection,
                                                                     java.util.Collection<GraphRequest> requests)
Executes requests that have already been serialized into an HttpURLConnection. No validation is done that the contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to ensure that it will correctly generate the desired responses.
This should only be called if you have transitioned off the UI thread.
Parameters:
connection - the HttpURLConnection that the requests were serialized into
requests - the requests represented by the HttpURLConnection
Returns:
a list of Responses corresponding to the requests
Throws:
FacebookException - If there was an error in the protocol used to communicate with the service

executeConnectionAndWait

public static java.util.List<GraphResponse> executeConnectionAndWait(java.net.HttpURLConnection connection,
                                                                     GraphRequestBatch requests)
Executes requests that have already been serialized into an HttpURLConnection. No validation is done that the contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to ensure that it will correctly generate the desired responses.
This should only be called if you have transitioned off the UI thread.
Parameters:
connection - the HttpURLConnection that the requests were serialized into
requests - the RequestBatch represented by the HttpURLConnection
Returns:
a list of Responses corresponding to the requests
Throws:
FacebookException - If there was an error in the protocol used to communicate with the service

executeConnectionAsync

public static GraphRequestAsyncTask executeConnectionAsync(java.net.HttpURLConnection connection,
                                                           GraphRequestBatch requests)
Asynchronously executes requests that have already been serialized into an HttpURLConnection. No validation is done that the contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to ensure that it will correctly generate the desired responses. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the setCallback method).
This should only be called from the UI thread.
Parameters:
connection - the HttpURLConnection that the requests were serialized into
requests - the requests represented by the HttpURLConnection
Returns:
a RequestAsyncTask that is executing the request

executeConnectionAsync

public static GraphRequestAsyncTask executeConnectionAsync(Handler callbackHandler,
                                                           java.net.HttpURLConnection connection,
                                                           GraphRequestBatch requests)
Asynchronously executes requests that have already been serialized into an HttpURLConnection. No validation is done that the contents of the connection actually reflect the serialized requests, so it is the caller's responsibility to ensure that it will correctly generate the desired responses. This function will return immediately, and the requests will be processed on a separate thread. In order to process results of a request, or determine whether a request succeeded or failed, a callback must be specified (see the setCallback method)
This should only be called from the UI thread.
Parameters:
callbackHandler - a Handler that will be used to post calls to the callback for each request; if null, a Handler will be instantiated on the calling thread
connection - the HttpURLConnection that the requests were serialized into
requests - the requests represented by the HttpURLConnection
Returns:
a RequestAsyncTask that is executing the request

toString

public java.lang.String toString()
Returns a string representation of this Request, useful for debugging.
Overrides:
toString in class java.lang.Object
Returns:
the debugging information