Skip to Content

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.

Screen Shot 2016-01-29 at 8.08.39 AM.png

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.

Screen Shot 2016-01-29 at 8.44.29 AM.png

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.

Screen Shot 2016-01-29 at 10.04.01 AM.png

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.

Screen Shot 2016-01-29 at 8.48.10 AM.png

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.

Screen Shot 2016-01-29 at 8.50.40 AM.png

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.

Screen Shot 2016-01-29 at 8.52.18 AM.png

Original

Screen Shot 2016-01-29 at 8.53.38 AM.png

Revised


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.

Screen Shot 2016-01-29 at 9.05.37 AM.png

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.

Screen Shot 2016-01-29 at 9.11.33 AM.png

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.

Screen Shot 2016-01-29 at 8.09.45 AM.png

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.

Screen Shot 2016-01-29 at 9.15.15 AM.png

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.

Screen Shot 2016-01-29 at 9.17.42 AM.png

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.

Screen Shot 2016-01-29 at 9.19.05 AM.png

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.

Screen Shot 2016-01-29 at 9.20.22 AM.png

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.

Screen Shot 2016-01-29 at 9.36.19 AM.png

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.

Screen Shot 2016-01-29 at 9.38.56 AM.png

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.

Screen Shot 2016-01-29 at 9.39.13 AM.png

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.

Screen Shot 2016-01-29 at 8.11.00 AM.png

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.

Screen Shot 2016-01-29 at 9.45.32 AM.png

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.

Screen Shot 2016-01-29 at 9.46.21 AM.png

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.

Screen Shot 2016-01-29 at 9.47.20 AM.png

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.

Screen Shot 2016-01-29 at 9.49.54 AM.png

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.

To report this post you need to login first.

15 Comments

You must be Logged on to comment or reply to a post.

  1. pranav kumar

    Hi Tahir,

    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

    Pranav Kumar

    from

    INDIA

    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.

    (0) 
  2. CHANDRA Pembarthi

    Hi..

    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…error in hana.png

    (0) 
    1. Tom Flanagan Post author

      Hi CHANDRA,

      Which version of the DP agent are you using? Are you using the most recent version available on the SAP Service Market Place?

      (0) 
    1. Tom Flanagan Post author

      Hi Sainath,

      Unfortunately it isn’t as this feature is available in SAP HANA SPS11. This is a new feature of Smart Data Integration.

      (0) 
  3. CHANDRA Pembarthi

    Hi,

    I am facing issue while extracting data from fb to hana.

    Below is error can you please help me in this..

    Error: (dberror) 403 – internal error: Remote execution error Camel execution failed. for query “SELECT “NEW_TV”.”id”, “NEW_TV”.”name”, “NEW_TV”.”category”, “NEW_TV”.”createdTime” FROM “TELEVISION” “NEW_TV” “

    (0) 
      1. Neeluri P

        Hi Tom,

         

        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.

         

        Kind Regards,

        Neeluri Parimala

        (0) 
  4. Paul Zemlyansky

    Hi,

    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?
     

    (0) 
  5. Vladimir Grigoriev

    @chandra.pembarthi

    I have the same error – do you know solution?
    Error: SAP DBTech JDBC: [403]: 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.

    (0) 
  6. Suraj Grewal

     

    Hello  ,

    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 com.sap.hana.dp.agentconfig.app.Application.start(Application.java:171)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515)

     

     

    (0) 

Leave a Reply