[SAP HANA Academy] Discover How to Connect SAP HANA to Facebook with the Apache Camel Facebook Adapter
In a trio of tutorial videos the SAP HANA Academy‘s Tahir Hussain “Bob” Babar details how to setup and use the Camel Facebook Adapter. The Camel Facebook Adapter is used to connect SAP HANA to Facebook. These videos are part of the SAP HANA Academy’s What’s New in SAP HANA SPS 11 series, with a specific focus on the new features of Smart Data Integration.
How to Setup the Data Provisioning Agent
The first video in the series shows how to setup the Data Provisioning Agent. Follow along with the video below.
Apache Camel is a framework for creating custom adapters using a few configuration files and spring domain specific language. Hardly any coding is necessary to set one up but you will need to know Apache Camel and Spring framework to preform advanced tasks.
Bob will be using the Camel Facebook Adapter, which is a pre-delivered component based upon the Camel adapter. You can use the Apache Camel Facebook Component to connect to and retrieve data from Facebook.
A few tasks must be preformed on the data provisioning machine so you can use the Camel Facebook Adapter. First, a pair of files must be downloaded. The initial file is the Facebook4J API, which basically provides the ability to connect to Facebook via its API.
In a browser navigate to the Facebook4J page from the Apache Camel Facebook component page. Here you have the option to download the latest version of Facebook4J. However, to follow along with this series you need an earlier version of Facebook4J. So Bob right clicks on the latest version listed on the webpage (facebook4J-core-2.4.2.jar) and selects to copy the link address. Bob then pastes the copied address in a new tab after http://facebook4j.org/download/ and changes the version number to 1.1.12. So Bob’s web address bar displays http://facebook4j.org/download/facebook4j-core-1.1.12.jar before he hits enter to download the file.
The second file that must be downloaded is the Apache Camel Facebook jar file. Navigate to the Camel downloads page and select the latest release 2.15.5 at the top of the page. If you would like an older version click on the see download archive link. Scroll down the page, click to download the apache-camel-2.15.5.zip file and then select one of the mirrors on the page you’re directed to. Bob downloads http://apache.mirror.iphh.net/came/apache-camel/2.15.5/apache-camel-2.15.5.zip.
Bob moves both of the files to his desktop. Bob opens the Apache Camel zip file and navigates to the lib folder. The only file that you need from the lib folder is camel-facebook-2.15.5.jar. Bob drags this file to his desktop and then deletes the zip file.
Next Bob opens the Camel folder located in his data provisioning agent folder on his Windows machine. Inside the Camel folder Bob creates a new folder called lib and moves the recently downloaded camel-facebook-2.15.5.jar and facebook4j-core-1.1.12.jar files into it.
You must also enable the adapter so that when you login to your data provisioning agent you will be able to see the Camel Facebook component. To accomplish this right click on the adapters.xml file in your Camel folder and choose to Edit with Notepad++. Bob moves the comment originally on line 18 to line 5. Now the lines below line 5 are visible.
Next you must register the Camel Facebook Adapter. Launch your Data Provisioning Agent and choose to connect to your SAP HANA box. In this video Bob covers the necessary rights that must be given when configuring your DP Agent including create agent, adapter admin, agent admin and create remote source. Once you successfully connect you should be able to see the CamelFacebookAdapter.
With CamelFacebookAdapter selected click on the Register Adapter button to register it on your DP Agent. Now we will be able to access the Camel Facebook Adapter in SAP HANA.
Setting proxies is not necessary. Bob demonstrates this by showing the blank screen for the CamelFacebookAdapter in the Preferences. The proxy can be configured in your remote source.
How to Create a Facebook Application and Generate the Keys to Connect to the Facebook API
In the second video in the series Bob shows how to create a Facebook application. This Facebook application will generate the keys that are needed to connect to the Facebook API.
Bob has created a sample Facebook account called Ryan Cantona. Bob will show how to extract data from this profile, specifically the Television Programmes Ryan has liked. At the moment Ryan likes four TV programmes.
The idea behind the application is that whenever Ryan likes a new show (or book, or gains a new friend) then that information will be registered instantly in SAP HANA.
When you connect through the Camel Facebook Adapter you won’t use your regular Facebook login credentials. So you must create an application which will generate four key. Those keys in turn will be used to authenticate your connection.
When logged into Facebook navigate to developers.facebook.com. Click on the My Apps button at the top and select the Add a New App. Choose Website, name the app and choose a Facebook ID. For Bob’s app he choose Entertainment as the Category before clicking create App ID.
On the setup SDK page scroll down to the bottom and enter your website URL (can be any URL) and click next. Bob’s URL is ryanssap.com. Now that the application is registered if you refresh the page you can view your app.
Select the newly created application and then copy the App ID number to a notepad. Then click on the Show button next to App Secret and record the App Secret number as well.
Next click on the Tools & Support tab and choose the Graph API Explorer tool. Then select your recently created app as the application and click on the Get Tokens button. On the Select Permissions window that pops up you can choose what categories of information you want to allow access to. In the User Data Permissions section Bob chooses user_about_me and user_likes. Bob doesn’t select any Extended Permissions.
Bob advises to not select the user_friends permission. Due to Facebook’s excellent security, your friends would have to use your application in order for it to access their information. The idea behind a similar product would be that a business would design a game or application on Facebook. The only way for people to play the game or access the application would be to agree to give the game/application permission to access their friends’ information.
Bob clicks the Get Access Token button and confirms what it will access. The access token is then listed and Bob records it for future use.
Back in the Tools & Support tab Bob clicks on the Access Token Tool. Next Bob selects Debug next to the User Token to display the User ID on the subsequent page.
After recording this key Bob now has his Facebook application’s App ID, App Secret, User ID and User Access Token. These four keys will be used when creating the remote source in SAP HANA.
How to Create a Remote Source in SAP HANA to Connect to Facebook
In the series’ third and final video Bob shows how to create a remote source in SAP HANA. This remote source will connect to Facebook using Smart Data Integration.
Log into the Catalog on the SAP HANA Web-based Development Workbench and navigate to the Remote Sources Folder in the Provisioning Folder. Right click and choose New Remote Source. Bob names his new remote source MyFacebook and chooses CamelFacebookApapter as his Adapter name. Bob’s Location is agent and his Agent (Group) Name is SHA_DP_Agent.
Next Bob configures his HTTP Proxy Host and Port. Then Bob sets his Credentials Mode as Technical User and then enters the four keys he got from the Facebook application he created in the last video.
After entering the four keys, Bob saves the remote source and clicks refresh to access his newly created MyFacebook remote source. Drilling down into the MyFacebook remote source shows the various objects from which you can create virtual tables.
Bob right clicks on TELEVISION and selects New Virtual Table. Bob names the table MyFacebook_TV and puts it in his SHA schema. Bob then opens the content of his MyFacebook_TV virtual table located in the SHA schema in his catalogue folder. The table lists the four programmes that Ryan Cantona likes and the date and time in which he liked each one.
To test the connection Bob likes a new TV show (Bugs Bunny) on Ryan Cantona’s Facebook profile and then refreshes the virtual table to see that Bugs Bunny Show is now listed and time stamped.
Note that the User Access Token you generate from your Facebook application only lasts for one hour.
This series showed how to use the Camel Facebook Adapter to connect SAP HANA to Facebook using Smart Data Integration in SAP HANA SPS 11.
For more tutorial videos about What’s New with SAP HANA SPS 11 please check out this playlist.
SAP HANA Academy – Over 1,300 free tutorials videos on SAP HANA, SAP Analytics and the SAP HANA Cloud Platform.
Follow us on Twitter @saphanaacademy and connect with us on LinkedIn to stay abreast of our latest free tutorials.
Well Done Good Job her for new commer Young at least to knw abt SAP HANA.. I like it.. to explain and how to see on Face Book as well.. Nice Document.. Insallah.. seriously .. i like it your Thoughts in terms of SAP as well fir everybody now a days asking HANA HANA HANA n all.
Good one ..
Thanks & Regards
I salute for founder for Face Book as well.
Bye Thxxxx a lottt.. i will try to achieve it first my mobile if anything Help kindly help m new one for SAP HANA.. m Learning sap/4 Hana Simple Finance..and I sap FICO Consulatant.
Bye take care.
When i trying to connect Facebook to hana.. i am not able to see camel folder in my DP agent folder.. Can you please help me in this plz..
I attached screen shot please check once...
Which version of the DP agent are you using? Are you using the most recent version available on the SAP Service Market Place?
HANA DP AGENT 1.0 SP01 PL01
@ Tom great step by step blog. Is this feature available for all versions of HANA .I am on SAP HANA Studio Version: 1.0.7000.
Unfortunately it isn't as this feature is available in SAP HANA SPS11. This is a new feature of Smart Data Integration.
I am facing issue while extracting data from fb to hana.
Below is error can you please help me in this..
Still facing same issue ..
Can you help me in this
That's odd sorry you're encountering this issue.
Did you use this older version of the Facebook4J API instead of the latest one?
I too got same error. Any solution.
I used Facebook4j-core-1.1.12.jar and camel-facebook-2.15.3.jar files and DP Agent version is SP03 Patch 9.
i copied both files (versions 2.15.5 & 1.1.12) to <DPAgent_root>/camel/lib and edited the adapters.xml. But I still don't see the Camel Facebook Adapter in the Data Provisioning Agent.
I'm working with a trial HCP account.
Can you help me?
I am facing same issue... adapter is not listed in DP AGENT. I am using DP Agent 2.0.
I have the same error - do you know solution?
Error: SAP DBTech JDBC: : internal error: Remote execution error Camel execution failed. for query "SELECT "myfacebook_ACCOUNT"."id", "myfacebook_ACCOUNT"."name", "myfacebook_ACCOUNT"."accessToken", "myfacebook_ACCOUNT"."category" FROM "ACCOUNT" "myfacebook_ACCOUNT" "
I deleted two files from LIB but have the same errror.
I have the same error - any solution yet?
I have successfully installed DP agent and I can see Camel folder as well in my dataprovagent.
JAR files have been copied in the lib folder .I have edited the Manifest file as well but when I am trying to open Configuration in C:\usr\sap\dataprovagent\configTool\dpagentconfigtool.exe it is showing me the below error which is traced in C:\usr\sap\dataprovagent\configTool\workspace\.metadata\.log .Below is the error .
java.lang.Exception: Config tool start failed
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)