Klasse DefaultFacebookClient
- Alle implementierten Schnittstellen:
FacebookClient
- Autor:
- Mark Allen
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenVon Schnittstelle geerbte verschachtelte Klassen/Schnittstellen com.restfb.FacebookClient
FacebookClient.AccessToken, FacebookClient.DebugTokenError, FacebookClient.DebugTokenInfo, FacebookClient.GranularScope
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected static final String
Reserved access token parameter name.protected String
Graph API access token.protected boolean
static final String
protected Version
Version of API endpoint.static final String
static final String
protected static final String
Reserved application secret proof parameter name.static final String
static final String
static final String
static final String
protected static final String
Reserved "result format" parameter name.protected boolean
By default this isfalse
, so real http DELETE is usedprotected static final String
Reserved "multiple IDs" parameter name.protected JsonMapper
Handles mapping Facebook response JSON to Java objects.protected static final String
Reserved method override parameter name.static final String
static final String
protected WebRequestor
HandlesGET
s andPOST
s to the Facebook API endpoint. -
Konstruktorübersicht
KonstruktorenModifiziererKonstruktorBeschreibungprotected
DefaultFacebookClient
(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
. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungconvertSessionKeysToAccessTokens
(String appId, String secretKey, String... sessionKeys) Converts an arbitrary number ofsessionKeys
to OAuth access tokens.createClientWithAccessToken
(String accessToken) creates a newFacebookClient
from a old one.protected String
createEndpointForApiCall
(String apiCall, boolean hasAttachment) 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.boolean
deleteObject
(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 APIConnection
type, mapping the result to an instance ofconnectionType
.<T> Connection<T>
fetchConnectionPage
(String connectionPageUrl, Class<T> connectionType) Fetches a previous/next page of a Graph APIConnection
type, mapping the result to an instance ofconnectionType
.fetchDeviceCode
(ScopeBuilder scope) Method to initialize the device access token generation.<T> T
fetchObject
(String object, Class<T> objectType, Parameter... parameters) Fetches a single Graph API object, mapping the result to an instance ofobjectType
.<T> T
fetchObjects
(List<String> ids, Class<T> objectType, Parameter... parameters) Fetches multiple Graph API objects in a single call, mapping the results to an instance ofobjectType
.fetch the current facebook exception generator implementing theFacebookExceptionGenerator
interfaceprotected String
Returns the base endpoint URL for the Graph API.protected String
Returns the base endpoint URL for the Graph API's video upload functionality.Gets theJsonMapper
used to convert Facebook JSON to Java objects.getLoginDialogUrl
(String appId, String redirectUri, ScopeBuilder scope, Parameter... parameters) generates the login dialog urlgetLogoutUrl
(String next) generates an logout urlGets theWebRequestor
used to talk to the Facebook API endpoints.boolean
returns if the fallback post method (true
) is used or the http delete (false
)protected 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.protected String
makeRequest
(String endpoint, boolean executeAsPost, boolean executeAsDelete, List<BinaryAttachment> binaryAttachments, Parameter... parameters) protected String
makeRequest
(String endpoint, Parameter... parameters) Coordinates the process of executing the API request GET/POST and processing the response we receive from the endpoint.protected String
obtainAppAccessToken
(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_proof
value.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.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 givenparameter
to the givenparameters
array.<T> T
parseSignedRequest
(String signedRequest, String appSecret, Class<T> objectType) Parses a signed request and verifies it against your App Secret.<T> T
publish
(String connection, Class<T> objectType, BinaryAttachment binaryAttachment, Parameter... parameters) Performs a Graph API publish operation on the givenconnection
and includes a file - a photo, for example - in the publish request, and mapping the result to an instance ofobjectType
.<T> T
Performs a Graph API publish operation on the givenconnection
and includes special body in the publish request, and mapping the result to an instance ofobjectType
.<T> T
Performs a Graph API publish operation on the givenconnection
, mapping the result to an instance ofobjectType
.<T> T
publish
(String connection, Class<T> objectType, List<BinaryAttachment> binaryAttachments, Parameter... parameters) Performs a Graph API publish operation on the givenconnection
and includes some files - photos, for example - in the publish request, and mapping the result to an instance ofobjectType
.void
setFacebookEndpointUrls
(FacebookEndpoints facebookEndpointUrls) void
setFacebookExceptionGenerator
(FacebookExceptionGenerator exceptionGenerator) override the default facebook exception generator to provide a custom handling for the facebook error objectsvoid
setHeaderAuthorization
(boolean accessTokenInHttpHeader) Switch between access token in header and access token in query parameters (default)void
setHttpDeleteFallback
(boolean httpDeleteFallback) Set totrue
if the facebook http delete fallback should be used.protected String
toParameterString
(boolean withJsonParameter, Parameter... parameters) Generate the parameter string to be included in the Facebook API request.protected String
toParameterString
(Parameter... parameters) Generate the parameter string to be included in the Facebook API request.protected String
urlDecodeSignedRequestToken
(String signedRequestToken) Decodes a component of a signed request received from Facebook using FB's special URL-encoding strategy.protected String
urlEncodedValueForParameterName
(String name, String value) Gets the URL-encoded version of the givenvalue
for the parameter namedname
.protected void
verifyParameterLegality
(Parameter... parameters) Verifies that the provided parameter names don't collide with the ones we internally pass along to Facebook.protected boolean
verifySignedRequest
(String appSecret, String algorithm, String encodedPayload, byte[] signature) Verifies that the signed request is really from Facebook.
-
Felddetails
-
CLIENT_ID
- Siehe auch:
-
APP_ID
- Siehe auch:
-
APP_SECRET
- Siehe auch:
-
SCOPE
- Siehe auch:
-
CANNOT_EXTRACT_ACCESS_TOKEN_MESSAGE
- Siehe auch:
-
PARAM_CLIENT_SECRET
- Siehe auch:
-
CONNECTION
- Siehe auch:
-
CONNECTION_TYPE
- Siehe auch:
-
ALGORITHM
- Siehe auch:
-
accessToken
Graph API access token. -
IDS_PARAM_NAME
Reserved "multiple IDs" parameter name.- Siehe auch:
-
apiVersion
Version of API endpoint. -
httpDeleteFallback
By default this isfalse
, so real http DELETE is used -
accessTokenInHeader
-
webRequestor
HandlesGET
s andPOST
s to the Facebook API endpoint. -
jsonMapper
Handles mapping Facebook response JSON to Java objects. -
METHOD_PARAM_NAME
Reserved method override parameter name.- Siehe auch:
-
FORMAT_PARAM_NAME
Reserved "result format" parameter name.- Siehe auch:
-
ACCESS_TOKEN_PARAM_NAME
Reserved access token parameter name.- Siehe auch:
-
APP_SECRET_PROOF_PARAM_NAME
Reserved application secret proof parameter name.- Siehe auch:
-
-
Konstruktordetails
-
DefaultFacebookClient
protected DefaultFacebookClient() -
DefaultFacebookClient
Creates a Facebook Graph API client with the givenapiVersion
.- Parameter:
apiVersion
- Version of the api endpoint
-
DefaultFacebookClient
Creates a Facebook Graph API client with the givenaccessToken
.- Parameter:
accessToken
- A Facebook OAuth access token.apiVersion
- Version of the api endpoint- Seit:
- 1.6.14
-
DefaultFacebookClient
Creates a Facebook Graph API client with the givenaccessToken
.- Parameter:
accessToken
- A Facebook OAuth access token.appSecret
- A Facebook application secret.apiVersion
- Version of the api endpoint- Seit:
- 1.6.14
-
DefaultFacebookClient
public DefaultFacebookClient(String accessToken, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion) Creates a Facebook Graph API client with the givenaccessToken
.- Parameter:
accessToken
- A Facebook OAuth access token.webRequestor
- TheWebRequestor
implementation to use for sending requests to the API endpoint.jsonMapper
- TheJsonMapper
implementation to use for mapping API response JSON to Java objects.apiVersion
- Version of the api endpoint- Löst aus:
NullPointerException
- IfjsonMapper
orwebRequestor
isnull
.- Seit:
- 1.6.14
-
DefaultFacebookClient
public DefaultFacebookClient(String accessToken, String appSecret, WebRequestor webRequestor, JsonMapper jsonMapper, Version apiVersion) Creates a Facebook Graph API client with the givenaccessToken
,webRequestor
, andjsonMapper
.- Parameter:
accessToken
- A Facebook OAuth access token.appSecret
- A Facebook application secret.webRequestor
- TheWebRequestor
implementation to use for sending requests to the API endpoint.jsonMapper
- TheJsonMapper
implementation to use for mapping API response JSON to Java objects.apiVersion
- Version of the api endpoint- Löst aus:
NullPointerException
- IfjsonMapper
orwebRequestor
isnull
.
-
-
Methodendetails
-
setHeaderAuthorization
Switch between access token in header and access token in query parameters (default)- Parameter:
accessTokenInHttpHeader
-true
use access token as header field,false
use access token as query parameter (default)
-
setFacebookExceptionGenerator
override the default facebook exception generator to provide a custom handling for the facebook error objects- Parameter:
exceptionGenerator
- the custom exception generator implementing theFacebookExceptionGenerator
interface
-
getFacebookExceptionGenerator
fetch the current facebook exception generator implementing theFacebookExceptionGenerator
interface- Gibt zurück:
- the current facebook exception generator
-
deleteObject
Beschreibung aus Schnittstelle kopiert:FacebookClient
Performs a Graph API delete operation on the givenobject
.- Angegeben von:
deleteObject
in SchnittstelleFacebookClient
- Parameter:
object
- The ID of the object to delete.parameters
- URL parameters to include in the API call.- Gibt zurück:
true
if Facebook indicated that the object was successfully deleted,false
otherwise.
-
fetchConnection
public <T> Connection<T> fetchConnection(String connection, Class<T> connectionType, Parameter... parameters) Beschreibung aus Schnittstelle kopiert:FacebookClient
Fetches a Graph APIConnection
type, mapping the result to an instance ofconnectionType
.- Angegeben von:
fetchConnection
in SchnittstelleFacebookClient
- Typparameter:
T
- Java type to map to.- Parameter:
connection
- The name of the connection, e.g."me/feed"
.connectionType
- Connection type token.parameters
- URL parameters to include in the API call (optional).- Gibt zurück:
- An instance of type
connectionType
which contains the requested Connection's data. - Siehe auch:
-
fetchConnectionPage
Beschreibung aus Schnittstelle kopiert:FacebookClient
Fetches a previous/next page of a Graph APIConnection
type, mapping the result to an instance ofconnectionType
.- Angegeben von:
fetchConnectionPage
in SchnittstelleFacebookClient
- Typparameter:
T
- Java type to map to.- Parameter:
connectionPageUrl
- The URL of the connection page to fetch, usually retrieved viaConnection.getPreviousPageUrl()
orConnection.getNextPageUrl()
.connectionType
- Connection type token.- Gibt zurück:
- An instance of type
connectionType
which contains the requested Connection's data. - Siehe auch:
-
fetchObject
Beschreibung aus Schnittstelle kopiert:FacebookClient
Fetches a single Graph API object, mapping the result to an instance ofobjectType
.- Angegeben von:
fetchObject
in SchnittstelleFacebookClient
- Typparameter:
T
- Java type to map to.- Parameter:
object
- ID of the object to fetch, e.g."me"
.objectType
- Object type token.parameters
- URL parameters to include in the API call (optional).- Gibt zurück:
- An instance of type
objectType
which contains the requested object's data. - Siehe auch:
-
createClientWithAccessToken
Beschreibung aus Schnittstelle kopiert:FacebookClient
creates a newFacebookClient
from a old one. App secret and and api version are taken from the original client.- Angegeben von:
createClientWithAccessToken
in SchnittstelleFacebookClient
- Parameter:
accessToken
- this accesstoken is used for the new client- Gibt zurück:
- a new Facebookclient
-
fetchObjects
Beschreibung aus Schnittstelle kopiert:FacebookClient
Fetches 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.- Angegeben von:
fetchObjects
in SchnittstelleFacebookClient
- Typparameter:
T
- Java type to map to.- Parameter:
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).- Gibt zurück:
- An instance of type
objectType
which contains the requested objects' data. - Siehe auch:
-
publish
public <T> T publish(String connection, Class<T> objectType, List<BinaryAttachment> binaryAttachments, Parameter... parameters) Beschreibung aus Schnittstelle kopiert:FacebookClient
Performs a Graph API publish operation on the givenconnection
and includes some files - photos, for example - in the publish request, and mapping the result to an instance ofobjectType
.- Angegeben von:
publish
in SchnittstelleFacebookClient
- Typparameter:
T
- Java type to map to.- Parameter:
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.- Gibt zurück:
- An instance of type
objectType
which contains the Facebook response to your publish request. - Siehe auch:
-
publish
public <T> T publish(String connection, Class<T> objectType, BinaryAttachment binaryAttachment, Parameter... parameters) Beschreibung aus Schnittstelle kopiert:FacebookClient
Performs a Graph API publish operation on the givenconnection
and includes a file - a photo, for example - in the publish request, and mapping the result to an instance ofobjectType
.- Angegeben von:
publish
in SchnittstelleFacebookClient
- Typparameter:
T
- Java type to map to.- Parameter:
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.- Gibt zurück:
- An instance of type
objectType
which contains the Facebook response to your publish request. - Siehe auch:
-
publish
Beschreibung aus Schnittstelle kopiert:FacebookClient
Performs a Graph API publish operation on the givenconnection
, mapping the result to an instance ofobjectType
.- Angegeben von:
publish
in SchnittstelleFacebookClient
- Typparameter:
T
- Java type to map to.- Parameter:
connection
- The Connection to publish to.objectType
- Object type token.parameters
- URL parameters to include in the API call.- Gibt zurück:
- An instance of type
objectType
which contains the Facebook response to your publish request. - Siehe auch:
-
publish
Beschreibung aus Schnittstelle kopiert:FacebookClient
Performs a Graph API publish operation on the givenconnection
and includes special body in the publish request, and mapping the result to an instance ofobjectType
.- Angegeben von:
publish
in SchnittstelleFacebookClient
- Typparameter:
T
- Java type to map to.- Parameter:
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.- Gibt zurück:
- An instance of type
objectType
which contains the Facebook response to your publish request.
-
getLogoutUrl
Beschreibung aus Schnittstelle kopiert:FacebookClient
generates an logout url- Angegeben von:
getLogoutUrl
in SchnittstelleFacebookClient
- Parameter:
next
- may be null, url the webpage should redirect after logout- Gibt zurück:
- the logout url
-
executeBatch
Beschreibung aus Schnittstelle kopiert:FacebookClient
Executes operations as a batch using the Batch API.- Angegeben von:
executeBatch
in SchnittstelleFacebookClient
- Parameter:
batchRequests
- The operations to execute.- Gibt zurück:
- The execution results in the order in which the requests were specified.
- Siehe auch:
-
executeBatch
Beschreibung aus Schnittstelle kopiert:FacebookClient
Executes operations as a batch using the Batch API.- Angegeben von:
executeBatch
in SchnittstelleFacebookClient
- Parameter:
batchRequests
- The operations to execute.- Gibt zurück:
- The execution results in the order in which the requests were specified.
- Siehe auch:
-
executeBatch
public List<BatchResponse> executeBatch(List<BatchRequest> batchRequests, List<BinaryAttachment> binaryAttachments) Beschreibung aus Schnittstelle kopiert:FacebookClient
Executes operations as a batch with binary attachments using the Batch API.- Angegeben von:
executeBatch
in SchnittstelleFacebookClient
- Parameter:
batchRequests
- The operations to execute.binaryAttachments
- Binary attachments referenced by the batch requests.- Gibt zurück:
- The execution results in the order in which the requests were specified.
- Siehe auch:
-
convertSessionKeysToAccessTokens
public List<FacebookClient.AccessToken> convertSessionKeysToAccessTokens(String appId, String secretKey, String... sessionKeys) Beschreibung aus Schnittstelle kopiert:FacebookClient
Converts an arbitrary number ofsessionKeys
to 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.
- Angegeben von:
convertSessionKeysToAccessTokens
in SchnittstelleFacebookClient
- Parameter:
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.- Gibt zurück:
- A list of access tokens ordered to correspond to the
sessionKeys
argument list. - Siehe auch:
-
obtainAppAccessToken
Beschreibung aus Schnittstelle kopiert:FacebookClient
Obtains an access token which can be used to perform Graph API operations on behalf of an application instead of a user.- Angegeben von:
obtainAppAccessToken
in SchnittstelleFacebookClient
- Parameter:
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.- Gibt zurück:
- The access token for the application identified by
appId
andappSecret
. - Siehe auch:
-
fetchDeviceCode
Beschreibung aus Schnittstelle kopiert:FacebookClient
Method to initialize the device access token generation. You receive aDeviceCode
instance and have to show the user theDeviceCode.getVerificationUri()
and theDeviceCode.getUserCode()
. The user have to enter the user code at the verification url. Save theDeviceCode.getCode()
to use it later, when polling Facebook with theFacebookClient.obtainDeviceAccessToken(java.lang.String)
method.- Angegeben von:
fetchDeviceCode
in SchnittstelleFacebookClient
- Parameter:
scope
- List of Permissions to request from the person using your app.- Gibt zurück:
- Instance of
DeviceCode
including the information to obtain the Device access token
-
obtainDeviceAccessToken
public FacebookClient.AccessToken obtainDeviceAccessToken(String code) throws FacebookDeviceTokenCodeExpiredException, FacebookDeviceTokenPendingException, FacebookDeviceTokenDeclinedException, FacebookDeviceTokenSlowdownException Beschreibung aus Schnittstelle kopiert:FacebookClient
Method to poll Facebook and fetch the Device Access Token. You have to use this method to check if the user confirms the authorization.FacebookOAuthException
can be thrown if the authorization is declined or still pending.- Angegeben von:
obtainDeviceAccessToken
in SchnittstelleFacebookClient
- Parameter:
code
- The device- Gibt zurück:
- An extended access token for the given
FacebookClient.AccessToken
. - Löst aus:
FacebookDeviceTokenCodeExpiredException
- theDeviceCode.getCode()
is expired, please fetch a newDeviceCode
.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
-
obtainUserAccessToken
public FacebookClient.AccessToken obtainUserAccessToken(String appId, String appSecret, String redirectUri, String verificationCode) Beschreibung aus Schnittstelle kopiert:FacebookClient
Obtains an access token which can be used to perform Graph API operations on behalf of a user.See Access Tokens.
- Angegeben von:
obtainUserAccessToken
in SchnittstelleFacebookClient
- Parameter:
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 theverificationCode
.verificationCode
- The verification code in the Graph API callback to the redirect URI.- Gibt zurück:
- The access token for the user identified by
appId
,appSecret
,redirectUri
andverificationCode
. - Siehe auch:
-
obtainExtendedAccessToken
Beschreibung aus Schnittstelle kopiert:FacebookClient
Convenience method which invokesFacebookClient.obtainExtendedAccessToken(String, String, String)
with the current access token.- Angegeben von:
obtainExtendedAccessToken
in SchnittstelleFacebookClient
- Parameter:
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.- Gibt zurück:
- An extended access token for the given
accessToken
. - Siehe auch:
-
obtainExtendedAccessToken
public FacebookClient.AccessToken obtainExtendedAccessToken(String appId, String appSecret, String accessToken) Beschreibung aus Schnittstelle kopiert:FacebookClient
Obtains an extended access token for the given existing, non-expired, short-lived access_token.- Angegeben von:
obtainExtendedAccessToken
in SchnittstelleFacebookClient
- Parameter:
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.- Gibt zurück:
- An extended access token for the given
accessToken
. - Siehe auch:
-
parseSignedRequest
Beschreibung aus Schnittstelle kopiert:FacebookClient
Parses a signed request and verifies it against your App Secret.- Angegeben von:
parseSignedRequest
in SchnittstelleFacebookClient
- Typparameter:
T
- class of objectType- Parameter:
signedRequest
- The signed request to parse.appSecret
- The secret for the app that can read this signed request.objectType
- Object type token.- Gibt zurück:
- An instance of type
objectType
which contains the decoded object embedded withinsignedRequest
.
-
urlDecodeSignedRequestToken
Decodes a component of a signed request received from Facebook using FB's special URL-encoding strategy.- Parameter:
signedRequestToken
- Token to decode.- Gibt zurück:
- The decoded token.
-
getLoginDialogUrl
public String getLoginDialogUrl(String appId, String redirectUri, ScopeBuilder scope, Parameter... parameters) Beschreibung aus Schnittstelle kopiert:FacebookClient
generates the login dialog url- Angegeben von:
getLoginDialogUrl
in SchnittstelleFacebookClient
- Parameter:
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 tohttps://www.facebook.com/connect/login_success.html
.scope
- List of Permissions to request from the person using your app.parameters
- List of additional parameters- Gibt zurück:
- the login dialog url
-
verifySignedRequest
protected boolean verifySignedRequest(String appSecret, String algorithm, String encodedPayload, byte[] signature) Verifies that the signed request is really from Facebook.- Parameter:
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 providedsignature
.signature
- The decoded signature extracted from the signed request. Compared against a signature generated fromencodedPayload
.- Gibt zurück:
true
if the signed request is verified,false
if not.
-
debugToken
Beschreibung aus Schnittstelle kopiert:FacebookClient
When 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_at
field is not returned for short-lived access tokens.- Angegeben von:
debugToken
in SchnittstelleFacebookClient
- Parameter:
inputToken
- The Access Token to debug.- Gibt zurück:
- A JsonObject containing the debug information for the accessToken.
- Siehe auch:
-
getJsonMapper
Beschreibung aus Schnittstelle kopiert:FacebookClient
Gets theJsonMapper
used to convert Facebook JSON to Java objects.- Angegeben von:
getJsonMapper
in SchnittstelleFacebookClient
- Gibt zurück:
- The
JsonMapper
used to convert Facebook JSON to Java objects. - Siehe auch:
-
getWebRequestor
Beschreibung aus Schnittstelle kopiert:FacebookClient
Gets theWebRequestor
used to talk to the Facebook API endpoints.- Angegeben von:
getWebRequestor
in SchnittstelleFacebookClient
- Gibt zurück:
- The
WebRequestor
used to talk to the Facebook API endpoints. - Siehe auch:
-
makeRequest
Coordinates the process of executing the API request GET/POST and processing the response we receive from the endpoint.- Parameter:
endpoint
- Facebook Graph API endpoint.parameters
- Arbitrary number of parameters to send along to Facebook as part of the API call.- Gibt zurück:
- The JSON returned by Facebook for the API call.
- Löst aus:
FacebookException
- If an error occurs while making the Facebook API POST or processing the response.
-
makeRequest
protected String makeRequest(String endpoint, boolean executeAsPost, boolean executeAsDelete, List<BinaryAttachment> binaryAttachments, Parameter... parameters) -
makeRequest
protected 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.- Parameter:
endpoint
- Facebook Graph API endpoint.executeAsPost
-true
to execute the web request as aPOST
,false
to execute as aGET
.executeAsDelete
-true
to add a special 'treat this request as aDELETE
' parameter.binaryAttachments
- A list of binary files to include in aPOST
request. Passnull
if no attachment should be sent.parameters
- Arbitrary number of parameters to send along to Facebook as part of the API call.- Gibt zurück:
- The JSON returned by Facebook for the API call.
- Löst aus:
FacebookException
- If an error occurs while making the Facebook API POST or processing the response.
-
obtainAppSecretProof
Beschreibung aus Schnittstelle kopiert:FacebookClient
Generates anappsecret_proof
value.See Facebook's 'securing requests' documentation for more info.
- Angegeben von:
obtainAppSecretProof
in SchnittstelleFacebookClient
- Parameter:
accessToken
- The access token required to generate theappsecret_proof
value.appSecret
- The secret for the app for which you'd like to generate theappsecret_proof
value.- Gibt zurück:
- A hex-encoded SHA256 hash as a
String
. - Siehe auch:
-
isHttpDeleteFallback
returns if the fallback post method (true
) is used or the http delete (false
)- Gibt zurück:
true
if POST is used instead of HTTP DELETE (default)
-
setHttpDeleteFallback
Set totrue
if 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- Parameter:
httpDeleteFallback
-true
if the the http Delete Fallback is used
-
makeRequestAndProcessResponse
-
toParameterString
Generate the parameter string to be included in the Facebook API request.- Parameter:
parameters
- Arbitrary number of extra parameters to include in the request.- Gibt zurück:
- The parameter string to include in the Facebook API request.
- Löst aus:
FacebookJsonMappingException
- If an error occurs when building the parameter string.
-
toParameterString
Generate the parameter string to be included in the Facebook API request.- Parameter:
withJsonParameter
- add additional parameter format with type jsonparameters
- Arbitrary number of extra parameters to include in the request.- Gibt zurück:
- The parameter string to include in the Facebook API request.
- Löst aus:
FacebookJsonMappingException
- If an error occurs when building the parameter string.
-
createEndpointForApiCall
Given 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.
- Parameter:
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?- Gibt zurück:
- An absolute endpoint URL to communicate with.
- Siehe auch:
-
BaseFacebookClient.createEndpointForApiCall(java.lang.String,boolean)
-
getFacebookGraphEndpointUrl
Returns the base endpoint URL for the Graph API.- Gibt zurück:
- The base endpoint URL for the Graph API.
-
getFacebookGraphVideoEndpointUrl
Returns the base endpoint URL for the Graph API's video upload functionality.- Gibt zurück:
- The base endpoint URL for the Graph API's video upload functionality.
- Seit:
- 1.6.5
-
getFacebookEndpointUrls
-
setFacebookEndpointUrls
-
parametersWithAdditionalParameter
protected Parameter[] parametersWithAdditionalParameter(Parameter parameter, Parameter... parameters) Appends the givenparameter
to the givenparameters
array.- Parameter:
parameter
- The parameter value to append.parameters
- The parameters to which the givenparameter
is appended.- Gibt zurück:
- A new array which contains both
parameter
andparameters
.
-
urlEncodedValueForParameterName
Gets the URL-encoded version of the givenvalue
for 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.
- Parameter:
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.- Gibt zurück:
- The URL-encoded version of the given
value
.
-
verifyParameterLegality
Verifies that the provided parameter names don't collide with the ones we internally pass along to Facebook.- Parameter:
parameters
- The parameters to check.- Löst aus:
IllegalArgumentException
- If there's a parameter name collision.
-