This project is retired. As Micronaut become core of the Grails starting at Grails 4, please, use Micronaut Facebook SDK instead.
The Facebook Platform is a set of APIs that make your application more social. Read more about integrating Facebook with your web site on the Facebook developer site.
This project contains the open source Grails Facebook SDK Plugin that allows you to integrate the Facebook Platform on a website/app powered by Grails.
This plugin is a port of the official Facebook PHP SDK to Grails 3.0.
It supports the latest OAuth2.0 authentication (required since October 1st 2011).
Grails Facebook SDK Plugin provides the following Grails artefacts:
- FacebookContext - A Spring bean to get current Facebook context in controllers, when running apps on Facebook.com or websites with the Facebook Platform.
- FacebookGraphClient - A client to call Facebook Graph API, which is a wrapper around the rock solid RestFB java library version 1.32.0 (released October 13, 2016).
- FacebookJSTagLib - A collection of tags to easily integrate Facebook JS SDK in your GSPs.
WARNING: Facebook API v3.0 is now used by default.
Declare the plugin dependency in the build.gradle file, as shown here:
dependencies {
...
compile "org.grails.plugins:facebook-sdk:4:0.0"
...
}
Create a Facebook app on Facebook Developers, in order to get your own app ID and app secret.
Add your Facebook app parameters to your grails-app/conf/application.yml:
grails:
plugin:
facebooksdk:
app:
id: {APP_ID}
permissions: {APP_PERMISSIONS} // Ex. ['email','user_photos']
secret: {APP_SECRET}
By default, latest Graph API v3.3 will be used.
You can override default settings with apiVersion
setting:
grails:
plugin:
facebooksdk:
apiVersion: v2.3
Since FacebookContext should be instantiated at each request, you must use prototype
scope for your Controllers (since Grails 2.3, singleton
is the default scope).
grails:
controllers:
defaultScope: prototype
Default jQuery selector is $
, if you require another one, you can define it globally in your grails-app/conf/application.groovy:
grails:
plugin:
facebooksdk:
customSelector: jQuery
To report any bug, please use the project Issues section on GitHub.
The Grails Facebook SDK is not an official Facebook SDK such as Javascript, PHP, iOS and Android SDKs.
It is developed by AgoraPulse.
The Grails Facebook SDK is licensed under the Apache Licence, Version 2.0.
- Default return type of
fetchObject
fromFacebookExtensions
is back toJsonObject
instead ofMap
- restfb upgrade - see https://github.com/restfb/restfb/blob/master/migrations.md
- removed
FacebookRestClient
andDefaultFacebookRestClient
- avoid using raw
JsonObject
as the class has completely changed i.g.JsonObject
from restfb 2.x implements own methodasBoolean()
which fails if the value is notboolean
so you need to do regularfoo != null
check for testing the presense of the returnedJsonObject
value
- removed
FacebookGraphClient
is now deprecated, useFacebookGraphClientService
to create instances ofFacebookClient
with similar capabilitiesFacebookExtensions
the most useful methods fromFacebookGraphClient
are now injected using extensions methods toFacebookClient
interface directly