Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Integrate facebook using mule esb

336 visualizaciones

Publicado el

Integrate facebook using mule esb

Publicado en: Tecnología
  • Sé el primero en comentar

Integrate facebook using mule esb

  1. 1. www.sanjeetpandey.com www.sanjeetpandey.com Prepared by – Sanjeet Pandey Integrate Facebook using Mule ESB
  2. 2. www.sanjeetpandey.com Overview  What is Facebook?  Versions and Assumptions  Configuring Facebook  Configuring Facebook Connector  Mule Flow for Facebook Authentication  Mule Flow for retrieving logged in user details  Mule Flow for publishing message in Facebook  Conclusion
  3. 3. www.sanjeetpandey.com What is Facebook? – 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 – As of February 2015 Facebook reached a market capitalization of $212 Billion – Facebook is currently the most famous social networking site
  4. 4. www.sanjeetpandey.com Versions and Assumptions • In this presentation, we are using – Facebook Connector 2.3.4 – Any point Studio – Mule ESB Server 3.5.2 • To use this application in your project, you will need a Facebook account for testing • You will need to create a new Facebook app under Facebook developer apps to be able to communicate with your Facebook account from Mule ESB application • We will be using OAuth2 authentication to connect to Facebook using Mule ESB Facebook Connector
  5. 5. www.sanjeetpandey.com Configuring Facebook  Go to https://developers.facebook.com/  Click on My Apps  Click on Create a New App button and you should be given a screen as shown below
  6. 6. www.sanjeetpandey.com  Add a unique display name, namespace and select a category.  Click on Create App Id. You should get a screen similar to one shown below  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
  7. 7. www.sanjeetpandey.com Configuring Facebook Connector  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 your Facebook App ID value to Consumer Key text box  Add your 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.  A screen shot and sample XML configuration is shown in the next slide
  8. 8. www.sanjeetpandey.com
  9. 9. www.sanjeetpandey.com Mule Flow for Facebook Authentication  Configure a flow as shown in the below picture  The XML configuration for this flow is given in the next slide
  10. 10. www.sanjeetpandey.com  If the app authorizes to Facebook app successfully, the connector returns two flow variables to Mule ESB flow which are “_oauthVerifier” and “OAuthAccessTokenId”  Using Choice router, we are checking weather the flow received an “OAuthAccessTokenId” or not and based on the response we are determining the success or failure of the Facebook authorization
  11. 11. www.sanjeetpandey.com  Deploy your app  Hit the following URL on the browser http://localhost:1111/facebookauthorize  Facebook will ask you to authorize your new app to connect to Facebook as shown below. Below screen will be prompted only first time when you run the app. Latest execution of your app will not prompt for approval.
  12. 12. www.sanjeetpandey.com  Click on Okay button and you should see a message on the browser as “Facebook Authorization Successful”  In order to publish or post a message on Facebook, you would need to submit the app for review and request for “publish_stream” access on developer apps.
  13. 13. www.sanjeetpandey.com Mule Flow for retrieving logged in user details  Let’s extend the previous authorize flow and use the authentication token to retrieve the logged in user details from Facebook.  Change your Mule flow as per the given flow picture
  14. 14. www.sanjeetpandey.com  The XML configuration for the new flow will be as shown below
  15. 15. www.sanjeetpandey.com  In this flow, we have used another operation on Facebook connector to retrieve the logged in user details and print them on the browser using Object to JSON transformer  Deploy your app  Hit the following URL on the browser http://localhost:1111/facebookauthorize  You should now see the logged in user details printed on your browser in JSON format
  16. 16. www.sanjeetpandey.com Mule Flow for publishing message in Facebook  Let’s extend the previous authorize flow and use the authentication token and user details to publish a message on user’s wall.  Change your Mule flow as per the given flow picture  The XML configuration for the new flow is given in the next slide
  17. 17. www.sanjeetpandey.com
  18. 18. www.sanjeetpandey.com  Deploy your app  Hit the following URL on the browser http://localhost:1111/facebookauthorize  You should now see a message on your browser as “Message posted on your wall.”  Check your Facebook wall and you should see a message published on your wall as “This is a greetings from Mule ESB app”  Please note that Facebook does not allow spam. Therefore, if you try posting same message twice in a short period of time, an exception will be thrown.
  19. 19. www.sanjeetpandey.com Conclusion • Mule ESB Facebook connector provides an easy way to connect to Facebook using Facebook OAuth2 authentication and allows performing several operations • The latest Facebook connector is simpler to use compared to the previous version of Facebook connectors • Facebook Connector is available for Mule ESB community edition
  20. 20. www.sanjeetpandey.com 20

×