Class DefaultFacebookClient
- All Implemented Interfaces:
- FacebookClient
- Direct Known Subclasses:
- DefaultInstagramLoginClient,- DefaultThreadsClient
- Author:
- Mark Allen
- 
Nested Class SummaryNested Classes
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final StringReserved access token parameter name.protected StringGraph API access token.protected booleanstatic final Stringprotected VersionVersion of API endpoint.static final Stringstatic final Stringprotected static final StringReserved application secret proof parameter name.protected static final Stringprotected StringGraph API app secret.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final StringReserved "result format" parameter name.static final Stringprotected booleanBy default, this isfalse, so real http DELETE is usedprotected static final StringReserved "multiple IDs" parameter name.protected JsonMapperHandles mapping Facebook response JSON to Java objects.protected static final StringReserved method override parameter name.static final Stringstatic final Stringstatic final Stringstatic final Stringprotected WebRequestorHandlesGETs andPOSTs to the Facebook API endpoint.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedDefaultFacebookClient(Version apiVersion) Creates a Facebook Graph API client with the givenapiVersion.DefaultFacebookClient(String accessToken, Version apiVersion) Creates a Facebook Graph API client with the givenaccessToken.DefaultFacebookClient(String accessToken, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion) Creates a Facebook Graph API client with the givenaccessToken.DefaultFacebookClient(String accessToken, String appSecret, Version apiVersion) Creates a Facebook Graph API client with the givenaccessToken.DefaultFacebookClient(String accessToken, String appSecret, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion) Creates a Facebook Graph API client with the givenaccessToken,webRequestor, andjsonMapper.
- 
Method SummaryModifier and TypeMethodDescriptionconvertSessionKeysToAccessTokens(String appId, String secretKey, String... sessionKeys) Converts an arbitrary number ofsessionKeysto OAuth access tokens.protected StringcreateBaseUrlForEndpoint(String apiCall, boolean hasAttachment, boolean hasReel) createClientWithAccessToken(String accessToken) creates a newFacebookClientfrom an old one.protected StringcreateEndpointForApiCall(String apiCall, boolean hasAttachment, boolean hasReel) Given an api call (e.g.debugToken(String inputToken) When working with access tokens, you may need to check what information is associated with them, such as its user or expiry.booleandeleteObject(String object, Parameter... parameters) Performs a Graph API delete operation on the givenobject.executeBatch(BatchRequest... batchRequests) Executes operations as a batch using the Batch API.executeBatch(List<BatchRequest> batchRequests) Executes operations as a batch using the Batch API.executeBatch(List<BatchRequest> batchRequests, List<BinaryAttachment> binaryAttachments) Executes operations as a batch with binary attachments using the Batch API.<T> Connection<T>fetchConnection(String connection, Class<T> connectionType, Parameter... parameters) Fetches a Graph APIConnectiontype, mapping the result to an instance ofconnectionType.<T> Connection<T>fetchConnectionPage(String connectionPageUrl, Class<T> connectionType) Fetches a previous/next page of a Graph APIConnectiontype, mapping the result to an instance ofconnectionType.fetchDeviceCode(ScopeBuilder scope) Method to initialize the device access token generation.<T> TfetchObject(String object, Class<T> objectType, Parameter... parameters) Fetches a single Graph API object, mapping the result to an instance ofobjectType.<T> TfetchObjects(List<String> ids, Class<T> objectType, Parameter... parameters) Fetches multiple Graph API objects in a single call, mapping the results to an instance ofobjectType.protected AccessTokengetAccessTokenFromResponse(String response) getBusinessLoginDialogUrl(String appId, String redirectUri, String configId, String state, Parameter... parameters) Generates the login dialog url for Businessfetch the current facebook exception generator implementing theFacebookExceptionGeneratorinterfaceprotected StringReturns the base endpoint URL for the Graph API.protected StringReturns the base endpoint URL for the Graph APIs video upload functionality.protected StringReturns the Facebook Reels Upload endpoint URL for handling the Reels Uploadprotected StringgetGenericLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, Supplier<String> endpointSupplier, String state, List<Parameter> parameters) Gets theJsonMapperused to convert Facebook JSON to Java objects.getLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, Parameter... parameters) generates the login dialog urlgetLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, String state, Parameter... parameters) generates the login dialog urlgetLogoutUrl(String next) generates an logout urlGets theWebRequestorused to talk to the Facebook API endpoints.booleanreturns if the fallback post method (true) is used or the http delete (false)protected StringmakeRequest(String endpoint, boolean executeAsPost, boolean executeAsDelete, List<BinaryAttachment> binaryAttachments, Body body, Parameter... parameters) Coordinates the process of executing the API request GET/POST and processing the response we receive from the endpoint.protected StringmakeRequest(String endpoint, boolean executeAsPost, boolean executeAsDelete, List<BinaryAttachment> binaryAttachments, Parameter... parameters) protected StringmakeRequest(String endpoint, Parameter... parameters) Coordinates the process of executing the API request GET/POST and processing the response we receive from the endpoint.protected StringobtainAppAccessToken(String appId, String appSecret) Obtains an access token which can be used to perform Graph API operations on behalf of an application instead of a user.obtainAppSecretProof(String accessToken, String appSecret) Generates anappsecret_proofvalue.Method to poll Facebook and fetch the Device Access Token.obtainExtendedAccessToken(String appId, String appSecret) Convenience method which invokesFacebookClient.obtainExtendedAccessToken(String, String, String)with the current access token.obtainExtendedAccessToken(String appId, String appSecret, String accessToken) Obtains an extended access token for the given existing, non-expired, short-lived access_token.Obtain a refreshed Instagram extended access token.obtainUserAccessToken(String appId, String appSecret, String redirectUri, String verificationCode) Obtains an access token which can be used to perform Graph API operations on behalf of a user.protected Parameter[]parametersWithAdditionalParameter(Parameter parameter, Parameter... parameters) Appends the givenparameterto the givenparametersarray.<T> TparseSignedRequest(String signedRequest, String appSecret, Class<T> objectType) Parses a signed request and verifies it against your App Secret.<T> Tpublish(String connection, Class<T> objectType, BinaryAttachment binaryAttachment, Parameter... parameters) Performs a Graph API publish operation on the givenconnectionand includes a file - a photo, for example - in the publish request, and mapping the result to an instance ofobjectType.<T> TPerforms a Graph API publish operation on the givenconnectionand includes special body in the publish request, and mapping the result to an instance ofobjectType.<T> TPerforms a Graph API publish operation on the givenconnection, mapping the result to an instance ofobjectType.<T> Tpublish(String connection, Class<T> objectType, List<BinaryAttachment> binaryAttachments, Parameter... parameters) Performs a Graph API publish operation on the givenconnectionand includes some files - photos, for example - in the publish request, and mapping the result to an instance ofobjectType.voidsetFacebookEndpointUrls(FacebookEndpoints facebookEndpointUrls) voidsetFacebookExceptionGenerator(FacebookExceptionGenerator exceptionGenerator) override the default facebook exception generator to provide a custom handling for the facebook error objectsvoidsetHeaderAuthorization(boolean accessTokenInHttpHeader) Switch between access token in header and access token in query parameters (default)voidsetHttpDeleteFallback(boolean httpDeleteFallback) Set totrueif the facebook http delete fallback should be used.protected StringtoParameterString(boolean withJsonParameter, Parameter... parameters) Generate the parameter string to be included in the Facebook API request.protected StringtoParameterString(Parameter... parameters) Generate the parameter string to be included in the Facebook API request.protected StringurlDecodeSignedRequestToken(String signedRequestToken) Decodes a component of a signed request received from Facebook using FB's special URL-encoding strategy.protected StringurlEncodedValueForParameterName(String name, String value) Gets the URL-encoded version of the givenvaluefor the parameter namedname.protected voidverifyParameterLegality(Parameter... parameters) Verifies that the provided parameter names don't collide with the ones we internally pass along to Facebook.protected booleanverifySignedRequest(String appSecret, String algorithm, String encodedPayload, byte[] signature) Verifies that the signed request is really from Facebook.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.restfb.FacebookClientisAppSecretProofWithTime
- 
Field Details- 
CLIENT_ID- See Also:
 
- 
APP_ID- See Also:
 
- 
APP_SECRET- See Also:
 
- 
SCOPE- See Also:
 
- 
CANNOT_EXTRACT_ACCESS_TOKEN_MESSAGE- See Also:
 
- 
PARAM_CLIENT_SECRET- See Also:
 
- 
CONNECTION- See Also:
 
- 
CONNECTION_TYPE- See Also:
 
- 
ALGORITHM- See Also:
 
- 
PATH_OAUTH_ACCESS_TOKEN- See Also:
 
- 
REDIRECT_URI- See Also:
 
- 
GRANT_TYPE- See Also:
 
- 
CODE- See Also:
 
- 
accessTokenGraph API access token.
- 
appSecretGraph API app secret.
- 
IDS_PARAM_NAMEReserved "multiple IDs" parameter name.- See Also:
 
- 
apiVersionVersion of API endpoint.
- 
httpDeleteFallbackBy default, this isfalse, so real http DELETE is used
- 
accessTokenInHeader
- 
webRequestorHandlesGETs andPOSTs to the Facebook API endpoint.
- 
jsonMapperHandles mapping Facebook response JSON to Java objects.
- 
METHOD_PARAM_NAMEReserved method override parameter name.- See Also:
 
- 
FORMAT_PARAM_NAMEReserved "result format" parameter name.- See Also:
 
- 
ACCESS_TOKEN_PARAM_NAMEReserved access token parameter name.- See Also:
 
- 
APP_SECRET_PROOF_PARAM_NAMEReserved application secret proof parameter name.- See Also:
 
- 
APP_SECRET_PROOF_TIME_PARAM_NAME- See Also:
 
 
- 
- 
Constructor Details- 
DefaultFacebookClientprotected DefaultFacebookClient()
- 
DefaultFacebookClientCreates a Facebook Graph API client with the givenapiVersion.- Parameters:
- apiVersion- Version of the api endpoint
 
- 
DefaultFacebookClientCreates a Facebook Graph API client with the givenaccessToken.- Parameters:
- accessToken- A Facebook OAuth access token.
- apiVersion- Version of the api endpoint
- Since:
- 1.6.14
 
- 
DefaultFacebookClientCreates a Facebook Graph API client with the givenaccessToken.- Parameters:
- accessToken- A Facebook OAuth access token.
- appSecret- A Facebook application secret.
- apiVersion- Version of the api endpoint
- Since:
- 1.6.14
 
- 
DefaultFacebookClientpublic DefaultFacebookClient(String accessToken, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion) Creates a Facebook Graph API client with the givenaccessToken.- Parameters:
- accessToken- A Facebook OAuth access token.
- webRequestor- The- WebRequestorimplementation to use for sending requests to the API endpoint.
- jsonMapper- The- JsonMapperimplementation to use for mapping API response JSON to Java objects.
- apiVersion- Version of the api endpoint
- Throws:
- NullPointerException- If- jsonMapperor- webRequestoris- null.
- Since:
- 1.6.14
 
- 
DefaultFacebookClientpublic DefaultFacebookClient(String accessToken, String appSecret, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion) Creates a Facebook Graph API client with the givenaccessToken,webRequestor, andjsonMapper.- Parameters:
- accessToken- A Facebook OAuth access token.
- appSecret- A Facebook application secret.
- webRequestor- The- WebRequestorimplementation to use for sending requests to the API endpoint.
- jsonMapper- The- JsonMapperimplementation to use for mapping API response JSON to Java objects.
- apiVersion- Version of the api endpoint
- Throws:
- NullPointerException- If- jsonMapperor- webRequestoris- null.
 
 
- 
- 
Method Details- 
setHeaderAuthorizationSwitch between access token in header and access token in query parameters (default)- Parameters:
- accessTokenInHttpHeader-- trueuse access token as header field,- falseuse access token as query parameter (default)
 
- 
setFacebookExceptionGeneratoroverride the default facebook exception generator to provide a custom handling for the facebook error objects- Parameters:
- exceptionGenerator- the custom exception generator implementing the- FacebookExceptionGeneratorinterface
 
- 
getFacebookExceptionGeneratorfetch the current facebook exception generator implementing theFacebookExceptionGeneratorinterface- Returns:
- the current facebook exception generator
 
- 
deleteObjectDescription copied from interface:FacebookClientPerforms a Graph API delete operation on the givenobject.- Specified by:
- deleteObjectin interface- FacebookClient
- Parameters:
- object- The ID of the object to delete.
- parameters- URL parameters to include in the API call.
- Returns:
- trueif Facebook indicated that the object was successfully deleted,- falseotherwise.
 
- 
fetchConnectionpublic <T> Connection<T> fetchConnection(String connection, Class<T> connectionType, Parameter... parameters) Description copied from interface:FacebookClientFetches a Graph APIConnectiontype, mapping the result to an instance ofconnectionType.- Specified by:
- fetchConnectionin interface- FacebookClient
- Type Parameters:
- T- Java type to map to.
- Parameters:
- connection- The name of the connection, e.g.- "me/feed".
- connectionType- Connection type token.
- parameters- URL parameters to include in the API call (optional).
- Returns:
- An instance of type connectionTypewhich contains the requested Connection's data.
- See Also:
 
- 
fetchConnectionPageDescription copied from interface:FacebookClientFetches a previous/next page of a Graph APIConnectiontype, mapping the result to an instance ofconnectionType.- Specified by:
- fetchConnectionPagein interface- FacebookClient
- Type Parameters:
- T- Java type to map to.
- Parameters:
- connectionPageUrl- The URL of the connection page to fetch, usually retrieved via- Connection.getPreviousPageUrl()or- Connection.getNextPageUrl().
- connectionType- Connection type token.
- Returns:
- An instance of type connectionTypewhich contains the requested Connection's data.
- See Also:
 
- 
fetchObjectDescription copied from interface:FacebookClientFetches a single Graph API object, mapping the result to an instance ofobjectType.- Specified by:
- fetchObjectin interface- FacebookClient
- Type Parameters:
- T- Java type to map to.
- Parameters:
- object- ID of the object to fetch, e.g.- "me".
- objectType- Object type token.
- parameters- URL parameters to include in the API call (optional).
- Returns:
- An instance of type objectTypewhich contains the requested object's data.
- See Also:
 
- 
createClientWithAccessTokenDescription copied from interface:FacebookClientcreates a newFacebookClientfrom an old one.App secret and api version are taken from the original client. - Specified by:
- createClientWithAccessTokenin interface- FacebookClient
- Parameters:
- accessToken- this accesstoken is used for the new client
- Returns:
- a new Facebookclient
 
- 
fetchObjectsDescription copied from interface:FacebookClientFetches multiple Graph API objects in a single call, mapping the results to an instance ofobjectType.You'll need to write your own container type ( objectType) to hold the results. See http://restfb.com for an example of how to do this.- Specified by:
- fetchObjectsin interface- FacebookClient
- Type Parameters:
- T- Java type to map to.
- Parameters:
- ids- IDs of the objects to fetch, e.g.- "me", "arjun".
- objectType- Object type token.
- parameters- URL parameters to include in the API call (optional).
- Returns:
- An instance of type objectTypewhich contains the requested objects' data.
- See Also:
 
- 
publishpublic <T> T publish(String connection, Class<T> objectType, List<BinaryAttachment> binaryAttachments, Parameter... parameters) Description copied from interface:FacebookClientPerforms a Graph API publish operation on the givenconnectionand includes some files - photos, for example - in the publish request, and mapping the result to an instance ofobjectType.- Specified by:
- publishin interface- FacebookClient
- Type Parameters:
- T- Java type to map to.
- Parameters:
- connection- The Connection to publish to.
- objectType- Object type token.
- binaryAttachments- The files to include in the publish request.
- parameters- URL parameters to include in the API call.
- Returns:
- An instance of type objectTypewhich contains the Facebook response to your publish request.
- See Also:
 
- 
publishpublic <T> T publish(String connection, Class<T> objectType, BinaryAttachment binaryAttachment, Parameter... parameters) Description copied from interface:FacebookClientPerforms a Graph API publish operation on the givenconnectionand includes a file - a photo, for example - in the publish request, and mapping the result to an instance ofobjectType.- Specified by:
- publishin interface- FacebookClient
- Type Parameters:
- T- Java type to map to.
- Parameters:
- connection- The Connection to publish to.
- objectType- Object type token.
- binaryAttachment- The file to include in the publish request.
- parameters- URL parameters to include in the API call.
- Returns:
- An instance of type objectTypewhich contains the Facebook response to your publish request.
- See Also:
 
- 
publishDescription copied from interface:FacebookClientPerforms a Graph API publish operation on the givenconnection, mapping the result to an instance ofobjectType.- Specified by:
- publishin interface- FacebookClient
- Type Parameters:
- T- Java type to map to.
- Parameters:
- connection- The Connection to publish to.
- objectType- Object type token.
- parameters- URL parameters to include in the API call.
- Returns:
- An instance of type objectTypewhich contains the Facebook response to your publish request.
- See Also:
 
- 
publishDescription copied from interface:FacebookClientPerforms a Graph API publish operation on the givenconnectionand includes special body in the publish request, and mapping the result to an instance ofobjectType.- Specified by:
- publishin interface- FacebookClient
- Type Parameters:
- T- Java type to map to.
- Parameters:
- connection- The Connection to publish to.
- objectType- Object type token.
- body- The body used in the POST request.
- parameters- URL parameters to include in the API call.
- Returns:
- An instance of type objectTypewhich contains the Facebook response to your publish request.
 
- 
getLogoutUrlDescription copied from interface:FacebookClientgenerates an logout url- Specified by:
- getLogoutUrlin interface- FacebookClient
- Parameters:
- next- may be null, url the webpage should redirect after logout
- Returns:
- the logout url
 
- 
executeBatchDescription copied from interface:FacebookClientExecutes operations as a batch using the Batch API.- Specified by:
- executeBatchin interface- FacebookClient
- Parameters:
- batchRequests- The operations to execute.
- Returns:
- The execution results in the order in which the requests were specified.
- See Also:
 
- 
executeBatchDescription copied from interface:FacebookClientExecutes operations as a batch using the Batch API.- Specified by:
- executeBatchin interface- FacebookClient
- Parameters:
- batchRequests- The operations to execute.
- Returns:
- The execution results in the order in which the requests were specified.
- See Also:
 
- 
executeBatchpublic List<BatchResponse> executeBatch(List<BatchRequest> batchRequests, List<BinaryAttachment> binaryAttachments) Description copied from interface:FacebookClientExecutes operations as a batch with binary attachments using the Batch API.- Specified by:
- executeBatchin interface- FacebookClient
- Parameters:
- batchRequests- The operations to execute.
- binaryAttachments- Binary attachments referenced by the batch requests.
- Returns:
- The execution results in the order in which the requests were specified.
- See Also:
 
- 
convertSessionKeysToAccessTokenspublic List<AccessToken> convertSessionKeysToAccessTokens(String appId, String secretKey, String... sessionKeys) Description copied from interface:FacebookClientConverts an arbitrary number ofsessionKeysto OAuth access tokens.See the Facebook Platform Upgrade Guide for details on how this process works and why you should convert your application's session keys if you haven't already. - Specified by:
- convertSessionKeysToAccessTokensin interface- FacebookClient
- Parameters:
- appId- A Facebook application ID.
- secretKey- A Facebook application secret key.
- sessionKeys- The Old REST API session keys to be converted to OAuth access tokens.
- Returns:
- A list of access tokens ordered to correspond to the sessionKeysargument list.
- See Also:
 
- 
obtainAppAccessTokenDescription copied from interface:FacebookClientObtains an access token which can be used to perform Graph API operations on behalf of an application instead of a user.- Specified by:
- obtainAppAccessTokenin interface- FacebookClient
- Parameters:
- appId- The ID of the app for which you'd like to obtain an access token.
- appSecret- The secret for the app for which you'd like to obtain an access token.
- Returns:
- The access token for the application identified by appIdandappSecret.
- See Also:
 
- 
fetchDeviceCodeDescription copied from interface:FacebookClientMethod to initialize the device access token generation.You receive a DeviceCodeinstance and have to show the user theDeviceCode.getVerificationUri()and theDeviceCode.getUserCode(). The user have to enter the user code at the verification url.Save the DeviceCode.getCode()to use it later, when polling Facebook with theFacebookClient.obtainDeviceAccessToken(java.lang.String)method.- Specified by:
- fetchDeviceCodein interface- FacebookClient
- Parameters:
- scope- List of Permissions to request from the person using your app.
- Returns:
- Instance of DeviceCodeincluding the information to obtain the Device access token
 
- 
obtainDeviceAccessTokenpublic AccessToken obtainDeviceAccessToken(String code) throws FacebookDeviceTokenCodeExpiredException, FacebookDeviceTokenPendingException, FacebookDeviceTokenDeclinedException, FacebookDeviceTokenSlowdownException Description copied from interface:FacebookClientMethod to poll Facebook and fetch the Device Access Token.You have to use this method to check if the user confirms the authorization. FacebookOAuthExceptioncan be thrown if the authorization is declined or still pending.- Specified by:
- obtainDeviceAccessTokenin interface- FacebookClient
- Parameters:
- code- The device
- Returns:
- An extended access token for the given AccessToken.
- Throws:
- FacebookDeviceTokenCodeExpiredException- the- DeviceCode.getCode()is expired, please fetch a new- DeviceCode.
- FacebookDeviceTokenPendingException- the user has not finished the authorisation process, yet. Please poll again later.
- FacebookDeviceTokenDeclinedException- the user declined the authorisation. You have to handle this problem.
- FacebookDeviceTokenSlowdownException- you tried too often to fetch the device access token. You have to use a larger interval
 
- 
obtainUserAccessTokenpublic AccessToken obtainUserAccessToken(String appId, String appSecret, String redirectUri, String verificationCode) Description copied from interface:FacebookClientObtains an access token which can be used to perform Graph API operations on behalf of a user.See Access Tokens. - Specified by:
- obtainUserAccessTokenin interface- FacebookClient
- Parameters:
- appId- The ID of the app for which you'd like to obtain an access token.
- appSecret- The secret for the app for which you'd like to obtain an access token.
- redirectUri- The redirect URI which was used to obtain the- verificationCode.
- verificationCode- The verification code in the Graph API callback to the redirect URI.
- Returns:
- The access token for the user identified by appId,appSecret,redirectUriandverificationCode.
- See Also:
 
- 
obtainExtendedAccessTokenDescription copied from interface:FacebookClientConvenience method which invokesFacebookClient.obtainExtendedAccessToken(String, String, String)with the current access token.- Specified by:
- obtainExtendedAccessTokenin interface- FacebookClient
- Parameters:
- appId- The ID of the app for which you'd like to obtain an extended access token.
- appSecret- The secret for the app for which you'd like to obtain an extended access token.
- Returns:
- An extended access token for the given accessToken.
- See Also:
 
- 
obtainRefreshedExtendedAccessTokenDescription copied from interface:FacebookClientObtain a refreshed Instagram extended access token.This method is used to refresh an existing Instagram extended access token. Extended access tokens expire after a certain period of time, and this method allows you to obtain a new one using the refresh token provided with the original extended access token. - Specified by:
- obtainRefreshedExtendedAccessTokenin interface- FacebookClient
- Returns:
- A new AccessTokenobject containing the refreshed access token, expiration time, and token type.
 
- 
obtainExtendedAccessTokenDescription copied from interface:FacebookClientObtains an extended access token for the given existing, non-expired, short-lived access_token.- Specified by:
- obtainExtendedAccessTokenin interface- FacebookClient
- Parameters:
- appId- The ID of the app for which you'd like to obtain an extended access token.
- appSecret- The secret for the app for which you'd like to obtain an extended access token.
- accessToken- The non-expired, short-lived access token to extend.
- Returns:
- An extended access token for the given accessToken.
- See Also:
 
- 
getAccessTokenFromResponse
- 
parseSignedRequestDescription copied from interface:FacebookClientParses a signed request and verifies it against your App Secret.- Specified by:
- parseSignedRequestin interface- FacebookClient
- Type Parameters:
- T- class of objectType
- Parameters:
- signedRequest- The signed request to parse.
- appSecret- The secret for the app that can read this signed request.
- objectType- Object type token.
- Returns:
- An instance of type objectTypewhich contains the decoded object embedded withinsignedRequest.
 
- 
urlDecodeSignedRequestTokenDecodes a component of a signed request received from Facebook using FB's special URL-encoding strategy.- Parameters:
- signedRequestToken- Token to decode.
- Returns:
- The decoded token.
 
- 
getLoginDialogUrlpublic String getLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, String state, Parameter... parameters) Description copied from interface:FacebookClientgenerates the login dialog url- Specified by:
- getLoginDialogUrlin interface- FacebookClient
- Parameters:
- appId- The ID of your app, found in your app's dashboard.
- redirectUri- The URL that you want to redirect the person logging in back to. This URL will capture the response from the Login Dialog. If you are using this in a webview within a desktop app, this must be set to- https://www.facebook.com/connect/login_success.html.
- scope- List of Permissions to request from the person using your app.
- state- The state parameter is used to prevent CSRF attacks.
- parameters- List of additional parameters
- Returns:
- the login dialog url
 
- 
getLoginDialogUrlpublic String getLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, Parameter... parameters) Description copied from interface:FacebookClientgenerates the login dialog url- Specified by:
- getLoginDialogUrlin interface- FacebookClient
- Parameters:
- appId- The ID of your app, found in your app's dashboard.
- redirectUri- The URL that you want to redirect the person logging in back to. This URL will capture the response from the Login Dialog. If you are using this in a webview within a desktop app, this must be set to- https://www.facebook.com/connect/login_success.html.
- scope- List of Permissions to request from the person using your app.
- parameters- List of additional parameters
- Returns:
- the login dialog url
 
- 
getBusinessLoginDialogUrlpublic String getBusinessLoginDialogUrl(String appId, String redirectUri, String configId, String state, Parameter... parameters) Description copied from interface:FacebookClientGenerates the login dialog url for Business- Specified by:
- getBusinessLoginDialogUrlin interface- FacebookClient
- Parameters:
- appId- The ID of your app, found in your app's dashboard.
- redirectUri- The URL that you want to redirect the person logging in back to. This URL will capture the response from the Login Dialog. If you are using this in a webview within a desktop app, this must be set to- https://www.facebook.com/connect/login_success.html.
- configId- The configuration ID that defines the permissions and settings, found in the product section of your app's dashboard.
- state- An optional string used to maintain state between the request and the callback.
- parameters- List of additional parameters
- Returns:
- the login dialog url
 
- 
getGenericLoginDialogUrlprotected String getGenericLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, Supplier<String> endpointSupplier, String state, List<Parameter> parameters) 
- 
verifySignedRequestprotected boolean verifySignedRequest(String appSecret, String algorithm, String encodedPayload, byte[] signature) Verifies that the signed request is really from Facebook.- Parameters:
- appSecret- The secret for the app that can verify this signed request.
- algorithm- Signature algorithm specified by FB in the decoded payload.
- encodedPayload- The encoded payload used to generate a signature for comparison against the provided- signature.
- signature- The decoded signature extracted from the signed request. Compared against a signature generated from- encodedPayload.
- Returns:
- trueif the signed request is verified,- falseif not.
 
- 
debugTokenDescription copied from interface:FacebookClientWhen working with access tokens, you may need to check what information is associated with them, such as its user or expiry. To get this information you can use the debug tool in the developer site, or you can use this function. You must instantiate your FacebookClient using your App Access Token, or a valid User Access Token from a developer of the app. Note that if your app is set to Native/Desktop in the Advanced settings of your App Dashboard, the underlying GraphAPI endpoint will not work with your app token unless you change the "App Secret in Client" setting to NO. If you do not see this setting, make sure your "App Type" is set to Native/Desktop and then press the save button at the bottom of the page. This will not affect apps set to Web. The response of the API call is a JSON array containing data and a map of fields. For example: { "data": { "app_id": 138483919580948, "application": "Social Cafe", "expires_at": 1352419328, "is_valid": true, "issued_at": 1347235328, "metadata": { "sso": "iphone-safari" }, "scopes": [ "email", "publish_actions" ], "user_id": 1207059 } }Note that the issued_atfield is not returned for short-lived access tokens.- Specified by:
- debugTokenin interface- FacebookClient
- Parameters:
- inputToken- The Access Token to debug.
- Returns:
- A JsonObject containing the debug information for the accessToken.
- See Also:
 
- 
getJsonMapperDescription copied from interface:FacebookClientGets theJsonMapperused to convert Facebook JSON to Java objects.- Specified by:
- getJsonMapperin interface- FacebookClient
- Returns:
- The JsonMapperused to convert Facebook JSON to Java objects.
- See Also:
 
- 
getWebRequestorDescription copied from interface:FacebookClientGets theWebRequestorused to talk to the Facebook API endpoints.- Specified by:
- getWebRequestorin interface- FacebookClient
- Returns:
- The WebRequestorused to talk to the Facebook API endpoints.
- See Also:
 
- 
makeRequestCoordinates the process of executing the API request GET/POST and processing the response we receive from the endpoint.- Parameters:
- endpoint- Facebook Graph API endpoint.
- parameters- Arbitrary number of parameters to send along to Facebook as part of the API call.
- Returns:
- The JSON returned by Facebook for the API call.
- Throws:
- FacebookException- If an error occurs while making the Facebook API POST or processing the response.
 
- 
makeRequestprotected String makeRequest(String endpoint, boolean executeAsPost, boolean executeAsDelete, List<BinaryAttachment> binaryAttachments, Parameter... parameters) 
- 
makeRequestprotected String makeRequest(String endpoint, boolean executeAsPost, boolean executeAsDelete, List<BinaryAttachment> binaryAttachments, Body body, Parameter... parameters) Coordinates the process of executing the API request GET/POST and processing the response we receive from the endpoint.- Parameters:
- endpoint- Facebook Graph API endpoint.
- executeAsPost-- trueto execute the web request as a- POST,- falseto execute as a- GET.
- executeAsDelete-- trueto add a special 'treat this request as a- DELETE' parameter.
- binaryAttachments- A list of binary files to include in a- POSTrequest. Pass- nullif no attachment should be sent.
- parameters- Arbitrary number of parameters to send along to Facebook as part of the API call.
- Returns:
- The JSON returned by Facebook for the API call.
- Throws:
- FacebookException- If an error occurs while making the Facebook API POST or processing the response.
 
- 
obtainAppSecretProofDescription copied from interface:FacebookClientGenerates anappsecret_proofvalue.See Facebook's 'securing requests' documentation for more info. - Specified by:
- obtainAppSecretProofin interface- FacebookClient
- Parameters:
- accessToken- The access token required to generate the- appsecret_proofvalue.
- appSecret- The secret for the app for which you'd like to generate the- appsecret_proofvalue.
- Returns:
- A hex-encoded SHA256 hash as a String.
- See Also:
 
- 
isHttpDeleteFallbackreturns if the fallback post method (true) is used or the http delete (false)- Returns:
- trueif POST is used instead of HTTP DELETE (default)
 
- 
setHttpDeleteFallbackSet totrueif the facebook http delete fallback should be used. Facebook allows to use the http POST with the parameter "method=delete" to override the post and use delete instead. This feature allow http client that do not support the whole http method set, to delete objects from facebook- Parameters:
- httpDeleteFallback-- trueif the http Delete Fallback is used
 
- 
makeRequestAndProcessResponse
- 
toParameterStringGenerate the parameter string to be included in the Facebook API request.- Parameters:
- parameters- Arbitrary number of extra parameters to include in the request.
- Returns:
- The parameter string to include in the Facebook API request.
- Throws:
- FacebookJsonMappingException- If an error occurs when building the parameter string.
 
- 
toParameterStringGenerate the parameter string to be included in the Facebook API request.- Parameters:
- withJsonParameter- add additional parameter format with type json
- parameters- Arbitrary number of extra parameters to include in the request.
- Returns:
- The parameter string to include in the Facebook API request.
- Throws:
- FacebookJsonMappingException- If an error occurs when building the parameter string.
 
- 
createEndpointForApiCallGiven an api call (e.g. "me" or "fql.query"), returns the correct FB API endpoint to use.Useful for returning the read-only API endpoint where possible. - Parameters:
- apiCall- The FB API call (Graph or Old REST API) for which we'd like an endpoint.
- hasAttachment- Are we including a multipart file when making this API call?
- hasReel- Is the binary attachment used as Facebook reel?
- Returns:
- An absolute endpoint URL to communicate with.
- See Also:
- 
- BaseFacebookClient.createEndpointForApiCall(java.lang.String,boolean,boolean)
 
 
- 
createBaseUrlForEndpoint
- 
getFacebookGraphEndpointUrlReturns the base endpoint URL for the Graph API.- Returns:
- The base endpoint URL for the Graph API.
 
- 
getFacebookGraphVideoEndpointUrlReturns the base endpoint URL for the Graph APIs video upload functionality.- Returns:
- The base endpoint URL for the Graph APIs video upload functionality.
- Since:
- 1.6.5
 
- 
getFacebookReelsUploadEndpointUrlReturns the Facebook Reels Upload endpoint URL for handling the Reels Upload- Returns:
- the Facebook Reels Upload endpoint URL
 
- 
getFacebookEndpointUrls
- 
setFacebookEndpointUrls
- 
parametersWithAdditionalParameterprotected Parameter[] parametersWithAdditionalParameter(Parameter parameter, Parameter... parameters) Appends the givenparameterto the givenparametersarray.- Parameters:
- parameter- The parameter value to append.
- parameters- The parameters to which the given- parameteris appended.
- Returns:
- A new array which contains both parameterandparameters.
 
- 
urlEncodedValueForParameterNameGets the URL-encoded version of the givenvaluefor the parameter namedname.Includes special-case handling for access token parameters where we check if the token is already URL-encoded - if so, we don't encode again. All other parameter types are always URL-encoded. - Parameters:
- name- The name of the parameter whose value should be URL-encoded and returned.
- value- The value of the parameter which should be URL-encoded and returned.
- Returns:
- The URL-encoded version of the given value.
 
- 
verifyParameterLegalityVerifies that the provided parameter names don't collide with the ones we internally pass along to Facebook.- Parameters:
- parameters- The parameters to check.
- Throws:
- IllegalArgumentException- If there's a parameter name collision.
 
 
-