2. Facebook is a social networking website
launched in February 2004. A user must
register before they can use Facebook. After
registering users can create a user profile,
add other users as friends, exchange
messages, post status updates and photos,
share videos and receive notifications when
others update their profiles. In this blog post,
a step by step process of integrating with
Facebook using Mule ESB Facebook connector
is shown.
3. In this blog post, we are using
◦ Facebook Connector 2.3.4
◦ Anypoint Studio
◦ Mule ESB Server 3.5.2
To use this application in the project, we will
need a Facebook account for testing
We need to create a new Facebook app under
Facebook developer apps to be able to
communicate with the Facebook account from
Mule ESB application
We will be using OAuth2 authentication to
connect to Facebook using Mule ESB Facebook
Connector
4. Go to https://developers.facebook.com/
Click on My Apps
Click on Create a New App button
Add a unique display name, namespace and
select a category
Click on Create App Id
Click on Show button and make a note of the
App ID and App Secret. The App ID and App
Secret will be used later in Mule Facebook
Connector configuration
5.
6.
7. Create a new Mule Application
Click on Global Elements tab in your main flow
Click on Create Button
Select Facebook under connector configuration group
Add Facebook App ID value to consumer key text box
Add Facebook secret key value to consumer secret
text box
Leave the scope text box empty. The default value for
scope is “email,read_stream,publish_stream” which
covers most of the access permissions
Click on Oauth tab and specify domain, local port and
remote port values.
12. If the app authorizes in to Facebook
successfully, the connector returns two flow
variables to Mule ESB flow which are
“_oauthVerifier” and “OAuthAccessTokenId”
Using Choice router, we can check whether
the flow received an “OAuthAccessTokenId”
or not and based on the response we would
be able to determine the success or failure of
the Facebook authorization.
13. Deploy the app
Hit the following URL on the browser
http://localhost:1111/facebookauthorize
Facebook will ask us to authorize the new app to
connect to Facebook. This authorization will be
needed only on the first time when running the
application.
Click on Okay button and we should see a message
on the browser as “Facebook Authorization
Successful”
In order to publish or post a message on Facebook,
we will need to submit the app for review and request
for “publish_stream” access on developer app.