Android SDK Version
- Mutable
- CollectionMapper
- AppCall
- CustomTab
- CustomTabUtils
- DialogFeature
- DialogPresenter
- FacebookDialogBase
- FacebookDialogFragment
- GamingAction
- FacebookWebFallbackDialog
- FragmentWrapper
- InstagramCustomTab
- PlatformServiceClient
- WebDialog
- AnalyticsEvents
- AttributionIdentifiers
- BoltsMeasurementEventListener
- BundleJSONConverter
- CallbackManagerImpl
- FacebookInitProvider
- FacebookRequestErrorClassification
- FacebookSignatureValidator
- FeatureManager
- FetchedAppGateKeepersManager
- FetchedAppSettings
- FetchedAppSettingsManager
- FileLruCache
- ImageDownloader
- ImageRequest
- ImageResponse
- ImageResponseCache
- InstallReferrerUtil
- InternalSettings
- LockOnGetVariable
- Logger
- NativeAppCallAttachmentStore
- NativeProtocol
- ServerProtocol
- SmartLoginOption
- UrlRedirectCache
- Utility
- Validate
- WorkQueue
- MessageDialog
- SendButton
- ShareButton
- ShareButtonBase
- GameRequestDialog
- ShareDialog
- MessageDialogFeature
- VideoUploader
- GameRequestValidation
- CameraEffectFeature
- CameraEffectJSONUtility
- LegacyNativeDialogParameters
- NativeDialogParameters
- ResultProcessor
- ShareConstants
- ShareContentValidation
- ShareDialogFeature
- ShareFeedContent
- ShareInternalUtility
- ShareStoryFeature
- WebDialogParameters
- ShareApi
- ShareBuilder
- Sharer
- Share
- ShareToMessengerParamsBuilder
- Messenger
- MessengerThreadParams
- MessengerUtils
- ShareToMessengerParams
- FacebookAppLinkResolver
- AppLinkData
- AppLinks
- AggregateException
- AppLink
- AppLinkResolver
- AppLinks
- CancellationToken
- CancellationTokenRegistration
- CancellationTokenSource
- Continuation
- ExecutorException
- Task
- TaskCompletionSource
- UnobservedTaskException
- AccessTokenTracker
- AuthenticationTokenTracker
- CustomTabActivity
- CustomTabMainActivity
- FacebookActivity
- FacebookAuthorizationException
- FacebookButtonBase
- FacebookCallback
- FacebookDialog
- FacebookDialogException
- LoginStatusCallback
- WebDialog
- AccessToken
- AccessTokenManager
- AccessTokenSource
- AuthenticationToken
- AuthenticationTokenCache
- AuthenticationTokenClaims
- AuthenticationTokenHeader
- AuthenticationTokenManager
- CallbackManager
- CurrentAccessTokenExpirationBroadcastReceiver
- FacebookBroadcastReceiver
- FacebookContentProvider
- FacebookException
- FacebookGraphResponseException
- FacebookOperationCanceledException
- FacebookRequestError
- FacebookSdk
- FacebookSdkNotInitializedException
- FacebookServiceException
- GraphRequest
- GraphRequestAsyncTask
- GraphRequestBatch
- GraphResponse
- HttpMethod
- LoggingBehavior
- Profile
- ProfileCache
- ProfileManager
- ProfileTracker
- ProgressNoopOutputStream
- ProgressOutputStream
- RequestProgress
- Common
- DeviceRequestsHelper
- EndToEndDumper
- CodeChallengeMethod
- CustomTabLoginMethodHandler
- CustomTabPrefetchHelper
- DeviceAuthDialog
- DeviceAuthMethodHandler
- GetTokenLoginMethodHandler
- KatanaProxyLoginMethodHandler
- LoginBehavior
- LoginClient
- LoginConfiguration
- LoginFragment
- LoginManager
- LoginMethodHandler
- LoginResult
- NativeAppLoginMethodHandler
- NonceUtil
- WebLoginMethodHandler
- WebViewLoginMethodHandler
- DefaultAudience
- LoginTargetApp
- DeviceLoginManager
- Login
- AppGroupCreationContent
- CameraEffectArguments
- CameraEffectTextures
- GameRequestContent
- ShareCameraEffectContent
- ShareContent
- ShareHashtag
- ShareLinkContent
- ShareMedia
- ShareMediaContent
- ShareMessengerActionButton
- ShareMessengerURLActionButton
- ShareModel
- ShareModelBuilder
- SharePhoto
- SharePhotoContent
- ShareStoryContent
- ShareVideo
- ShareVideoContent
- AccessTokenAppIdPair
- AppEvent
- AppEventsConstants
- AppEventsLogger
- AppEventsManager
- FlushResult
- InternalAppEventsLogger
- UserDataStore
- MetadataIndexer
- MetadataRule
- SettingsAPIFields
- AppEventsCAPIManager
- CustomEventField
- AppEventType
- AppEventUserAndAppDataField
- ConversionsAPISection
- ConversionsAPICustomEventField
- ConversionsAPIUserAndAppDataField
- ConversionsAPIEventName
- OtherEventConstants
- AppEventsConversionsAPITransformer
- AppEventsConversionsAPITransformerWebRequests
- CodelessLoggingEventListener
- CodelessManager
- RCTCodelessLoggingEventListener
- ViewIndexer
- Constants
- EventBinding
- ParameterComponent
- PathComponent
- SensitiveUserDataUtils
- UnityReflection
- ViewHierarchy
- EventDeactivationManager
- InAppPurchaseActivityLifecycleTracker
- InAppPurchaseAutoLogger
- InAppPurchaseBillingClientWrapper
- InAppPurchaseEventManager
- InAppPurchaseLoggerManager
- InAppPurchaseManager
- InAppPurchaseSkuDetailsWrapper
- InAppPurchaseUtils
- IntegrityManager
- ActivityLifecycleTracker
- AppEventUtility
- AppEventsLoggerUtility
- AutomaticAnalyticsLogger
- Constants
- FileDownloadTask
- ViewHierarchyConstants
- MTensor
- Model
- ModelManager
- Utils
- OnDeviceProcessingManager
- RemoteServiceWrapper
- RestrictiveDataManager
- SuggestedEventsManager
- ViewOnClickListener
- Core
- GateKeeper
- GateKeeperRuntimeCache
- ExceptionAnalyzer
- InstrumentData
- InstrumentManager
- InstrumentUtility
- ANRDetector
- ANRHandler
- CrashHandler
- AutoHandleExceptions
- CrashShieldHandler
- NoAutoExceptionHandling
- ErrorReportData
- ErrorReportHandler
- ThreadCheckHandler
- Excuse
- ExcusesForDesignViolations
- CertificateUtil
- OidcSecurityUtil
- DeviceLoginButton
- LoginButton
- ProfilePictureView
- ToolTipPopup
- All
public final class GraphRequest
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 | Description |
---|---|---|
public class | GraphRequest.Companion | |
public 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. |
public 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. The frequency of the callbacks can be controlled using FacebookSdk.setOnProgressThreshold |
public interface | GraphRequest.GraphJSONArrayCallback | Callback for requests that result in an array of JSONObjects. |
public interface | GraphRequest.GraphJSONObjectCallback | Callback for requests that result in a JSONObject. |
public final class | GraphRequest.ParcelableResourceWithMimeType |
Field Summary
Modifier and Type | Field | Description |
---|---|---|
private AccessToken | accessToken | |
private String | graphPath | |
private JSONObject | graphObject | |
private String | batchEntryName | |
private String | batchEntryDependsOn | |
private Boolean | batchEntryOmitResultOnSuccess | |
private Bundle | parameters | |
private Object | tag | |
private String | version | |
private GraphRequest.Callback | callback | |
private HttpMethod | httpMethod | |
private final String | relativeUrlForBatchedRequest | |
private final String | urlForSingleRequest |
Constructor Summary
Constructor | Description |
---|---|
GraphRequest(AccessToken accessToken, String graphPath, Bundle parameters, HttpMethod httpMethod, GraphRequest.Callback callback, String version) | Constructs a request with a specific access token, graph path, parameters, and HTTP method. |
GraphRequest(AccessToken accessToken, 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, String graphPath, Bundle parameters, HttpMethod httpMethod) | Constructs a request with a specific access token, graph path, parameters, and HTTP method. |
GraphRequest(AccessToken accessToken, String graphPath, Bundle parameters) | Constructs a request with a specific access token, graph path, parameters, and HTTP method. |
GraphRequest(AccessToken accessToken, String graphPath) | Constructs a request with a specific access token, graph path, parameters, and HTTP method. |
GraphRequest(AccessToken accessToken) | Constructs a request with a specific access token, graph path, parameters, and HTTP method. |
GraphRequest() | Constructs a request with a specific access token, graph path, parameters, and HTTP method. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
final AccessToken | getAccessToken() | The access token associated with this request. |
final Unit | setAccessToken(AccessToken accessToken) | The access token associated with this request. |
final String | getGraphPath() | The graph path of this request, if any. |
final Unit | setGraphPath(String graphPath) | The graph path of this request, if any. |
final JSONObject | getGraphObject() | The GraphObject, if any, associated with this request. |
final Unit | setGraphObject(JSONObject graphObject) | The GraphObject, if any, associated with this request. |
final String | getBatchEntryName() | The name of this requests entry in a batched request. |
final Unit | setBatchEntryName(String batchEntryName) | The name of this requests entry in a batched request. |
final String | getBatchEntryDependsOn() | The name of the request that this request entry explicitly depends on in a batched request. |
final Unit | setBatchEntryDependsOn(String batchEntryDependsOn) | The name of the request that this request entry explicitly depends on in a batched request. |
final Boolean | getBatchEntryOmitResultOnSuccess() | Whether or not this batch entry will return a response if it is successful. |
final Unit | setBatchEntryOmitResultOnSuccess(Boolean batchEntryOmitResultOnSuccess) | Whether or not this batch entry will return a response if it is successful. |
final Bundle | getParameters() | The parameters for this request. |
final Unit | setParameters(Bundle parameters) | The parameters for this request. |
final Object | getTag() | The tag on the request; this is an application-defined object that can be used to distinguish between different requests. |
final Unit | setTag(Object tag) | The tag on the request; this is an application-defined object that can be used to distinguish between different requests. |
final String | getVersion() | The version of the API that this request will use. |
final Unit | setVersion(String version) | The version of the API that this request will use. |
final GraphRequest.Callback | getCallback() | The callback which will be called when the request finishes. |
final Unit | setCallback(GraphRequest.Callback callback) | |
final HttpMethod | getHttpMethod() | The HttpMethod to use for this request. |
final Unit | setHttpMethod(HttpMethod httpMethod) | |
final String | getRelativeUrlForBatchedRequest() | |
final String | getUrlForSingleRequest() | |
final Unit | setForceApplicationRequest(Boolean forceOverride) | This is an internal function that is not meant to be used by developers. |
final GraphResponse | executeAndWait() | Executes this request on the current thread and blocks while waiting for the response. |
final GraphRequestAsyncTask | executeAsync() | Executes the request asynchronously. |
String | toString() | Returns a string representation of this Request, useful for debugging. |
Constructor Detail
GraphRequest
GraphRequest(AccessToken accessToken, String graphPath, Bundle parameters, HttpMethod httpMethod, GraphRequest.Callback callback, String version)
Constructs a request with a specific access token, graph path, parameters, and HTTP method.
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.callback
- a callback that will be called when the request is completed to handle success or error conditionsversion
- the version of the Graph APIGraphRequest
GraphRequest(AccessToken accessToken, String graphPath, Bundle parameters, HttpMethod httpMethod, GraphRequest.Callback callback)
Constructs a request with a specific access token, graph path, parameters, and HTTP method.
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.callback
- a callback that will be called when the request is completed to handle success or error conditionsGraphRequest
GraphRequest(AccessToken accessToken, String graphPath, Bundle parameters, HttpMethod httpMethod)
Constructs a request with a specific access token, graph path, parameters, and HTTP method.
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.GraphRequest
GraphRequest(AccessToken accessToken, String graphPath, Bundle parameters)
Constructs a request with a specific access token, graph path, parameters, and HTTP method.
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.GraphRequest
GraphRequest(AccessToken accessToken, String graphPath)
Constructs a request with a specific access token, graph path, parameters, and HTTP method.
Parameters:
accessToken
- the access token to use, or nullgraphPath
- the graph path to retrieve, create, or deleteGraphRequest
GraphRequest(AccessToken accessToken)
Constructs a request with a specific access token, graph path, parameters, and HTTP method.
Parameters:
accessToken
- the access token to use, or nullGraphRequest
GraphRequest()
Constructs a request with a specific access token, graph path, parameters, and HTTP method.
Method Detail
getAccessToken
final AccessTokengetAccessToken()
The access token associated with this request. Null if none has been specified.
setAccessToken
final UnitsetAccessToken(AccessToken accessToken)
The access token associated with this request. Null if none has been specified.
getGraphPath
final StringgetGraphPath()
The graph path of this request, if any. Null if there is none.
setGraphPath
final UnitsetGraphPath(String graphPath)
The graph path of this request, if any. Null if there is none.
getGraphObject
final JSONObjectgetGraphObject()
The GraphObject, if any, associated with this request. Null if there is none. This is meaningful only for POST requests.
setGraphObject
final UnitsetGraphObject(JSONObject graphObject)
The GraphObject, if any, associated with this request. Null if there is none. This is meaningful only for POST requests.
getBatchEntryName
final StringgetBatchEntryName()
The name of this requests entry in a batched request. Null if none has been specified. 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.
It must be unique within a particular batch of requests.
setBatchEntryName
final UnitsetBatchEntryName(String batchEntryName)
The name of this requests entry in a batched request. Null if none has been specified. 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.
It must be unique within a particular batch of requests.
getBatchEntryDependsOn
final StringgetBatchEntryDependsOn()
The name of the request that this request entry 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.
setBatchEntryDependsOn
final UnitsetBatchEntryDependsOn(String batchEntryDependsOn)
The name of the request that this request entry 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.
getBatchEntryOmitResultOnSuccess
final BooleangetBatchEntryOmitResultOnSuccess()
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. Null if none has been specified See Batch Requests in the Graph API documentation for more details.
setBatchEntryOmitResultOnSuccess
final UnitsetBatchEntryOmitResultOnSuccess(Boolean batchEntryOmitResultOnSuccess)
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. Null if none has been specified See Batch Requests in the Graph API documentation for more details.
getTag
final ObjectgetTag()
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.
setTag
final UnitsetTag(Object tag)
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.
getVersion
final StringgetVersion()
The version of the API that this request will use. By default this is the current API at the time the SDK is released. Only use this if you need to explicitly override.
setVersion
final UnitsetVersion(String version)
The version of the API that this request will use. By default this is the current API at the time the SDK is released. Only use this if you need to explicitly override.
getCallback
final GraphRequest.CallbackgetCallback()
The callback which will be called when the request finishes.
setCallback
final UnitsetCallback(GraphRequest.Callback callback)
getHttpMethod
final HttpMethodgetHttpMethod()
The HttpMethod to use for this request. Assign null for default (HttpMethod.GET)
setHttpMethod
final UnitsetHttpMethod(HttpMethod httpMethod)
getRelativeUrlForBatchedRequest
final StringgetRelativeUrlForBatchedRequest()
getUrlForSingleRequest
final StringgetUrlForSingleRequest()
setForceApplicationRequest
final UnitsetForceApplicationRequest(Boolean forceOverride)
This is an internal function that is not meant to be used by developers.
executeAndWait
final GraphResponseexecuteAndWait()
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.
executeAsync
final GraphRequestAsyncTaskexecuteAsync()
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.