Android SDK Version
- AccessToken
- AccessToken.AccessTokenCreationCallback
- AccessToken.AccessTokenRefreshCallback
- AccessTokenManager
- AccessTokenSource
- AccessTokenTracker
- AddressFilterManager
- All
- AppEvent
- AppEventsConstants
- AppEventsLogger
- AppEventsLogger.FlushBehavior
- AppEventsLogger.ProductAvailability
- AppEventsLogger.ProductCondition
- AppEventsManager
- AppGroupCreationContent
- AppGroupCreationContent.AppGroupPrivacy
- AppGroupCreationContent.Builder
- AppInviteContent
- AppInviteContent.Builder
- AppInviteContent.Builder.Destination
- AppInviteDialog
- AppInviteDialog.Result
- AppLinkData
- AppLinkData.CompletionHandler
- AppLinks
- CallbackManager
- CallbackManager.Factory
- CameraEffectArguments
- CameraEffectArguments.Builder
- CameraEffectTextures
- CameraEffectTextures.Builder
- CodelessLoggingEventListener
- CodelessLoggingEventListener.AutoLoggingOnClickListener
- CodelessLoggingEventListener.AutoLoggingOnItemClickListener
- CodelessManager
- Common
- Core
- CreateAppGroupDialog
- CreateAppGroupDialog.Result
- CurrentAccessTokenExpirationBroadcastReceiver
- CurrentPlaceFeedbackRequestParams
- CurrentPlaceFeedbackRequestParams.Builder
- CurrentPlaceRequestParams
- CurrentPlaceRequestParams.Builder
- CurrentPlaceRequestParams.ConfidenceLevel
- CurrentPlaceRequestParams.ScanMode
- CustomTabActivity
- CustomTabLoginMethodHandler
- CustomTabMainActivity
- DefaultAudience
- DeviceAuthDialog
- DeviceLoginButton
- DeviceLoginManager
- DeviceShareButton
- DeviceShareDialog
- DeviceShareDialog.Result
- EventDeactivationManager
- FacebookActivity
- FacebookAppLinkResolver
- FacebookAuthorizationException
- FacebookBroadcastReceiver
- FacebookButtonBase
- FacebookCallback
- FacebookContentProvider
- FacebookDialog
- FacebookDialogException
- FacebookException
- FacebookGraphResponseException
- FacebookOperationCanceledException
- FacebookRequestError
- FacebookRequestError.Category
- FacebookSdk
- FacebookSdk.InitializeCallback
- FacebookSdkNotInitializedException
- FacebookServiceException
- FlushResult
- GameRequestContent
- GameRequestContent.ActionType
- GameRequestContent.Builder
- GameRequestContent.Filters
- GameRequestDialog
- GameRequestDialog.Result
- GraphRequest
- GraphRequest.Callback
- GraphRequest.GraphJSONArrayCallback
- GraphRequest.GraphJSONObjectCallback
- GraphRequest.OnProgressCallback
- GraphRequest.ParcelableResourceWithMimeType
- GraphRequestAsyncTask
- GraphRequestBatch
- GraphRequestBatch.Callback
- GraphRequestBatch.OnProgressCallback
- GraphResponse
- GraphResponse.PagingDirection
- HttpMethod
- InternalAppEventsLogger
- JoinAppGroupDialog
- JoinAppGroupDialog.Result
- LikeView
- LikeView.AuxiliaryViewPosition
- LikeView.HorizontalAlignment
- LikeView.ObjectType
- LikeView.OnErrorListener
- LikeView.Style
- LoggingBehavior
- Login
- LoginBehavior
- LoginButton
- LoginButton.ToolTipMode
- LoginFragment
- LoginManager
- LoginResult
- LoginStatusCallback
- MessageDialog
- Messenger
- MessengerThreadParams
- MessengerThreadParams.Origin
- MessengerUtils
- MetadataIndexer
- Model
- ModelManager
- PlaceFields
- PlaceInfoRequestParams
- PlaceInfoRequestParams.Builder
- PlaceManager
- PlaceManager.LocationError
- PlaceManager.OnRequestReadyCallback
- Places
- PlaceSearchRequestParams
- PlaceSearchRequestParams.Builder
- Profile
- ProfileManager
- ProfilePictureView
- ProfilePictureView.OnErrorListener
- ProfileTracker
- RCTCodelessLoggingEventListener
- RCTCodelessLoggingEventListener.AutoLoggingOnTouchListener
- RestrictiveDataManager
- SendButton
- Share
- ShareApi
- ShareBuilder
- ShareButton
- ShareButtonBase
- ShareCameraEffectContent
- ShareCameraEffectContent.Builder
- ShareContent
- ShareContent.Builder
- ShareDialog
- ShareDialog.Mode
- ShareGraphRequest
- ShareHashtag
- ShareHashtag.Builder
- ShareLinkContent
- ShareLinkContent.Builder
- ShareMedia
- ShareMedia.Builder
- ShareMedia.Type
- ShareMediaContent
- ShareMediaContent.Builder
- ShareMessengerActionButton
- ShareMessengerActionButton.Builder
- ShareMessengerGenericTemplateContent
- ShareMessengerGenericTemplateContent.Builder
- ShareMessengerGenericTemplateContent.ImageAspectRatio
- ShareMessengerGenericTemplateElement
- ShareMessengerGenericTemplateElement.Builder
- ShareMessengerMediaTemplateContent
- ShareMessengerMediaTemplateContent.Builder
- ShareMessengerMediaTemplateContent.MediaType
- ShareMessengerOpenGraphMusicTemplateContent
- ShareMessengerOpenGraphMusicTemplateContent.Builder
- ShareMessengerURLActionButton
- ShareMessengerURLActionButton.Builder
- ShareMessengerURLActionButton.WebviewHeightRatio
- ShareModel
- ShareModelBuilder
- ShareOpenGraphAction
- ShareOpenGraphAction.Builder
- ShareOpenGraphContent
- ShareOpenGraphContent.Builder
- ShareOpenGraphObject
- ShareOpenGraphObject.Builder
- ShareOpenGraphValueContainer
- ShareOpenGraphValueContainer.Builder
- SharePhoto
- SharePhoto.Builder
- SharePhotoContent
- SharePhotoContent.Builder
- Sharer
- Sharer.Result
- ShareStoryContent
- ShareStoryContent.Builder
- ShareToMessengerParams
- ShareToMessengerParamsBuilder
- ShareVideo
- ShareVideo.Builder
- ShareVideoContent
- ShareVideoContent.Builder
- SuggestedEventsManager
- ToolTipPopup
- ToolTipPopup.Style
- UserDataStore
- Utils
- ViewIndexer
- ViewOnClickListener
- WebDialog
- 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 Type | Class 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 Type | Field and Description |
---|---|
static java.lang.String | ACCESS_TOKEN_PARAM |
static java.lang.String | FIELDS_PARAM |
static int | MAXIMUM_BATCH_SIZE The maximum number of requests that can be submitted in a single batch. |
static java.lang.String | TAG |
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 Type | Method and Description |
---|---|
GraphResponse | executeAndWait() Executes this request on the current thread and blocks while waiting for the response. |
static GraphResponse | executeAndWait(GraphRequest request) Executes a single request on the current thread and blocks while waiting for the response. |
GraphRequestAsyncTask | executeAsync() 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 GraphRequestAsyncTask | executeBatchAsync(java.util.Collection<GraphRequest> requests) Executes requests as a single batch asynchronously. |
static GraphRequestAsyncTask | executeBatchAsync(GraphRequest... requests) Executes requests as a single batch asynchronously. |
static GraphRequestAsyncTask | executeBatchAsync(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 GraphRequestAsyncTask | executeConnectionAsync(Handler callbackHandler, java.net.HttpURLConnection connection, GraphRequestBatch requests) Asynchronously executes requests that have already been serialized into an HttpURLConnection. |
static GraphRequestAsyncTask | executeConnectionAsync(java.net.HttpURLConnection connection, GraphRequestBatch requests) Asynchronously executes requests that have already been serialized into an HttpURLConnection. |
AccessToken | getAccessToken() Returns the access token associated with this request. |
java.lang.String | getBatchEntryDependsOn() Returns the name of the request that this request entry explicitly depends on in a batched request. |
java.lang.String | getBatchEntryName() Returns the name of this requests entry in a batched request. |
boolean | getBatchEntryOmitResultOnSuccess() Returns whether or not this batch entry will return a response if it is successful. |
GraphRequest.Callback | getCallback() Returns the callback which will be called when the request finishes. |
static java.lang.String | getDefaultBatchApplicationId() Gets the default Facebook application ID that will be used to submit batched requests. |
JSONObject | getGraphObject() Returns the GraphObject, if any, associated with this request. |
java.lang.String | getGraphPath() Returns the graph path of this request, if any. |
HttpMethod | getHttpMethod() Returns the HttpMethod to use for this request. |
Bundle | getParameters() Returns the parameters for this request. |
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. |
java.lang.String | getVersion() Returns the version of the API that this request will use. |
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. |
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. |
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. |
static GraphRequest | newGraphPathRequest(AccessToken accessToken, java.lang.String graphPath, GraphRequest.Callback callback) Creates a new Request configured to retrieve a particular graph path. |
static GraphRequest | newMeRequest(AccessToken accessToken, GraphRequest.GraphJSONObjectCallback callback) Creates a new Request configured to retrieve a user's own profile. |
static GraphRequest | newMyFriendsRequest(AccessToken accessToken, GraphRequest.GraphJSONArrayCallback callback) Creates a new Request configured to retrieve a user's friend list. |
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. |
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. |
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. |
static GraphRequest | newUploadPhotoRequest(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 GraphRequest | newUploadPhotoRequest(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. |
void | setAccessToken(AccessToken accessToken) Sets the access token to use for this request. |
void | setBatchEntryDependsOn(java.lang.String batchEntryDependsOn) Sets the name of the request entry that this request explicitly depends on in a batched request. |
void | setBatchEntryName(java.lang.String batchEntryName) Sets the name of this request's entry in a batched request. |
void | setBatchEntryOmitResultOnSuccess(boolean batchEntryOmitResultOnSuccess) Sets whether or not this batch entry will return a response if it is successful. |
void | setCallback(GraphRequest.Callback callback) Sets the callback which will be called when the request finishes. |
static 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. |
void | setGraphObject(JSONObject graphObject) Sets the GraphObject associated with this request. |
void | setGraphPath(java.lang.String graphPath) Sets the graph path of this request. |
void | setHttpMethod(HttpMethod httpMethod) Sets the HttpMethod to use for this request. |
void | setParameters(Bundle parameters) Sets the parameters for this request. |
void | setSkipClientToken(boolean skipClientToken) This is an internal function that is not meant to be used by developers. |
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. |
void | setVersion(java.lang.String version) Set the version to use for this request. |
static java.net.HttpURLConnection | toHttpConnection(java.util.Collection<GraphRequest> requests) Serializes one or more requests but does not execute them. |
static java.net.HttpURLConnection | toHttpConnection(GraphRequest... requests) Serializes one or more requests but does not execute them. |
static java.net.HttpURLConnection | toHttpConnection(GraphRequestBatch requests) Serializes one or more requests but does not execute them. |
java.lang.String | toString() Returns a string representation of this Request, useful for debugging. |
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.
See Also:
TAG
public static final java.lang.String TAG
ACCESS_TOKEN_PARAM
public static final java.lang.String ACCESS_TOKEN_PARAM
See Also:
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 nullgraphPath
- the graph path to retrieveGraphRequest
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 nullgraphPath
- the graph path to retrieve, create, or deleteparameters
- 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 nullgraphPath
- the graph path to retrieve, create, or deleteparameters
- 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 conditionsGraphRequest
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 nullgraphPath
- the graph path to retrieve, create, or deleteparameters
- 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 conditionsversion
- the version of the Graph APIMethod 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 nullid
- the id of the object to deletecallback
- a callback that will be called when the request is completed to handle success or error conditionsReturns:
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 nullcallback
- a callback that will be called when the request is completed to handle success or error conditionsReturns:
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 nullgraphPath
- the graph path to retrieve, create, or deletegraphObject
- the graph object to create or updatecallback
- a callback that will be called when the request is completed to handle success or error conditionsReturns:
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 nullcallback
- a callback that will be called when the request is completed to handle success or error conditionsReturns:
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 nullgraphPath
- the graph path to retrievecallback
- a callback that will be called when the request is completed to handle success or error conditionsReturns:
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 nulllocation
- the location around which to search; only the latitude and longitude components of the location are meaningfulradiusInMeters
- the radius around the location to search, specified in meters; this is ignored if no location is specifiedresultsLimit
- the maximum number of results to returnsearchText
- optional text to search for as part of the name or type of an objectcallback
- a callback that will be called when the request is completed to handle success or error conditionsReturns:
a Request that is ready to execute
Throws:
FacebookException
- If neither location nor searchText is specifiednewUploadPhotoRequest
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 nullgraphPath
- the graph path to use, defaults to me/photosimage
- the bitmap image to uploadcaption
- the user generated caption for the photo, can be nullparams
- the parameters, can be nullcallback
- a callback that will be called when the request is completed to handle success or error conditions, can be nullReturns:
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 nullgraphPath
- the graph path to use, defaults to me/photosfile
- the file containing the photo to uploadcaption
- the user generated caption for the photo, can be nullparams
- the parameters, can be nullcallback
- a callback that will be called when the request is completed to handle success or error conditions, can be nullReturns:
a Request that is ready to execute
Throws:
java.io.FileNotFoundException
- if the file doesn't existnewUploadPhotoRequest
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 nullgraphPath
- the graph path to use, defaults to me/photosphotoUri
- the file:// or content:// Uri to the photo on devicecaption
- the user generated caption for the photo, can be nullparams
- the parameters, can be nullcallback
- a callback that will be called when the request is completed to handle success or error conditions, can be nullReturns:
a Request that is ready to execute
Throws:
java.io.FileNotFoundException
- if the Uri does not existnewCustomAudienceThirdPartyIdRequest
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 requestgetGraphPath
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 requestgetHttpMethod
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 parametersgetAccessToken
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 requestgetBatchEntryName
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 requestsgetBatchEntryDependsOn
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 requestgetBatchEntryOmitResultOnSuccess
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 requestgetDefaultBatchApplicationId
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 determinedgetCallback
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 callbacksetTag
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 nullgetTag
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 servicejava.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 serializeReturns:
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 servicejava.lang.IllegalArgumentException
- if the passed in array is zero-lengthjava.lang.NullPointerException
- if the passed in array or any of its contents are nulltoHttpConnection
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 serializeReturns:
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 servicejava.lang.IllegalArgumentException
- if the passed in collection is emptyjava.lang.NullPointerException
- if the passed in collection or any of its contents are nulltoHttpConnection
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 serializeReturns:
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 servicejava.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 executeReturns:
the Response object representing the results of the request
Throws:
FacebookException
- If there was an error in the protocol used to communicate with the serviceexecuteBatchAndWait
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 executeReturns:
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 requestFacebookException
- If there was an error in the protocol used to communicate with the serviceexecuteBatchAndWait
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 executeReturns:
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 serviceexecuteBatchAndWait
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 executeReturns:
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 servicejava.lang.IllegalArgumentException
- if the passed in RequestBatch is emptyjava.lang.NullPointerException
- if the passed in RequestBatch or any of its contents are nullexecuteBatchAsync
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 executeReturns:
a RequestAsyncTask that is executing the request
Throws:
java.lang.NullPointerException
- If a null request is passed inexecuteBatchAsync
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 executeReturns:
a RequestAsyncTask that is executing the request
Throws:
java.lang.IllegalArgumentException
- if the passed in collection is emptyjava.lang.NullPointerException
- if the passed in collection or any of its contents are nullexecuteBatchAsync
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 executeReturns:
a RequestAsyncTask that is executing the request
Throws:
java.lang.IllegalArgumentException
- if the passed in RequestBatch is emptyjava.lang.NullPointerException
- if the passed in RequestBatch or any of its contents are nullexecuteConnectionAndWait
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 intorequests
- the requests represented by the HttpURLConnectionReturns:
a list of Responses corresponding to the requests
Throws:
FacebookException
- If there was an error in the protocol used to communicate with the serviceexecuteConnectionAndWait
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 intorequests
- the RequestBatch represented by the HttpURLConnectionReturns:
a list of Responses corresponding to the requests
Throws:
FacebookException
- If there was an error in the protocol used to communicate with the serviceexecuteConnectionAsync
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 intorequests
- the requests represented by the HttpURLConnectionReturns:
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 threadconnection
- the HttpURLConnection that the requests were serialized intorequests
- the requests represented by the HttpURLConnectionReturns:
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