Generic properties
There are a number of properties available for configuring Facebook4J. You can specify properties via facebook4j.properties file, ConfigurationBuilder class or System Property as follows :
via facebook4j.properties
Save a standard properties file named “facebook4j.properties”. Place it to either the current directory, root of the classpath directory.
debug=true
oauth.appId=****************
oauth.appSecret=********************************
oauth.accessToken=********************************
oauth.permissions=email,publish_stream,...
via ConfigurationBuilder
You can use ConfigurationBuilder class to configure Facebook4J programatically as follows:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthAppId("*********************")
.setOAuthAppSecret("******************************************")
.setOAuthAccessToken("**************************************************")
.setOAuthPermissions("email,publish_stream,...");
FacebookFactory ff = new FacebookFactory(cb.build());
Facebook facebook = ff.getInstance();
via System Properties
You can configure Facebook4J via System properties as well. Note that you need “facebook4j.” prefix.
$ java -Dfacebook4j.debug=true
-Dfacebook4j.oauth.appId=*********************
-Dfacebook4j.oauth.appSecret=******************************************
-Dfacebook4j.oauth.accessToken=**************************************************
-Dfacebook4j.oauth.permissions=email,publish_stream,...
-cp facebook4j-core-2.4.13.jar:yourApp.jar yourpackage.Main
via environment variables
You can configure Facebook4J via environment variables as well. Note that you need “facebook4j.” prefix. This makes it easier to test, stage and deploy apps running on Heroku.
$ export facebook4j.debug=true
$ export facebook4j.oauth.appId=*********************
$ export facebook4j.oauth.appSecret=******************************************
$ export facebook4j.oauth.accessToken=**************************************************
$ export facebook4j.oauth.permissions=email,publish_stream,...
$ java -cp facebook4j-core-2.4.13.jar:yourApp.jar yourpackage.Main
On Heroku:
$ heroku config:add facebook4j.oauth.appId=*********************
$ heroku config:add facebook4j.oauth.appSecret=******************************************
$ heroku config:add facebook4j.oauth.accessToken=**************************************************
$ heroku config:add facebook4j.oauth.permissions=email,publish_stream,...
$ git push heroku master
Available Configuration Properties
Misc.
Property name | Description | Default value |
---|---|---|
debug | Enables deubg output. Effective only with the embedded logger. | false |
jsonStoreEnabled | If set to true, raw JSON forms will be stored in DataObjectFactory. | false |
mbeanEnabled | If set to true, mbean will be registerd. | false |
loggerFactory | Logger implimentation Supported implimentations: facebook4j.internal.logging.SLF4JLoggerFactory facebook4j.internal.logging.CommonsLoggingLoggerFactory facebook4j.internal.logging.Log4JLoggerFactory facebook4j.internal.logging.JULLoggerFactory facebook4j.internal.logging.NullLoggerFactory facebook4j.internal.logging.StdNullLoggerFactory | null |
OAuth
Property name | Description | Default value |
---|---|---|
oauth.appId | Default OAuth App ID | null |
oauth.appSecret | Default OAuth App Secret | null |
oauth.accessToken | Default OAuth access token | null |
oauth.permissions | Default OAuth permissions Comma separeted permission names See https://developers.facebook.com/docs/reference/login/#permissions for the detail. | null |
oauth.callbackURL | Default OAuth callback URL | null |
Security
Property name | Description | Default value |
---|---|---|
security.appSecretProofEnabled | If set to true, 'appsecret_proof' parameter will be added to every API call automatically. | false |
security.appSecretProofCacheSize | Cache size for computed appsecret_proof. | 10 |
HTTP connection
Property name | Description | Default value |
---|---|---|
http.connectionTimeout | Http connection timeout in milliseconds | 20000 |
http.readTimeout | Http read timeout in milliseconds | 120000 |
http.retryCount | Number of HTTP retries | 0 |
http.retryIntervalSecs | HTTP retry interval in seconds | 5 |
http.prettyDebug | prettify JSON debug output if set to true. | false |
HTTP proxy server
Property name | Description | Default value |
---|---|---|
http.proxyHost | HTTP proxy server host name | null |
http.proxyPort | HTTP proxy server port | null |
http.proxyUser | HTTP proxy server user name | null |
http.proxyPassword | HTTP proxy server password | null |
Base URLs
Property name | Description | Default value |
---|---|---|
restBaseURL | API base URL | https://graph.facebook.com/ |
videoBaseURL | Video API base URL | https://graph-video.facebook.com/ |
oauth.authorizationURL | OAuth authorization URL | https://www.facebook.com/dialog/oauth |
oauth.accessTokenURL | OAuth access token URL | https://graph.facebook.com/oauth/access_token |
oauth.accessTokenInfoURL | OAuth access token information URL | https://graph.facebook.com/oauth/access_token_info |
oauth.deviceTokenURL | OAuth device access token URL | http://graph.facebook.com/oauth/device |
Logger Configuration
By default, Facebook4J prints log messages to standard output. If any of SLF4J, Commons-Logging, Log4J is in the classpath, log messages will be printed via the available logging library. You can disable logging by specifying -Dfacebook4j.loggerFactory=facebook4j.internal.logging.NullLoggerFactory to the system properties.