Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

In a trio of tutorial videos the SAP HANA Academy's tahirhussain.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.

Original

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.

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.

15 Comments
Labels in this area