CRM and CX Blogs by SAP
Stay up-to-date on the latest developments and product news about intelligent customer experience and CRM technologies through blog posts from SAP experts.
cancel
Showing results for 
Search instead for 
Did you mean: 
AbinashNanda
Product and Topic Expert
Product and Topic Expert

To use the cloud-c4c-extension-sample Application for creating marketing lead we need to use various Facebook tokens. The aim of this blog is to show how to generate those tokens.

Note: This document is only limited to showcase how to create a basic Facebook app to be used with for this specific scenario and how to generate the required tokens.  Development of productize Facebook App is beyond the scope. Additionally Facebook API can change over time and no guarantee the steps mentioned here will work as is. As per Facebook documentation Apps that are in development mode will not receive real time
updates. Please consult developers.facebook.com for further information and any issues you might face.

Prerequisites: You already have created a Facebook as explained in the last blog.

To generate tokens we will use Facebook Graph API Explorer under the Tools & Support tab.

APP Token

App token can be generated as shown below

PAGE Token

For Page token first we need to set the relevant permissions. Click on Get token and in the Extended permissions section check email and manage_pages (optional for this app)

This will return us a short lived page token, which we need to exchange for a long lived exchanged token (expiry 60 days)

GET /oauth/access_token?grant_type=fb_exchange_token&client_id={app-id}&client_secret={app-secret}& fb_exchange_token={short-lived-token}

 
We need to provide this page token in the local.properties file

Real time Subscription

Next we need to add real time subscription for our Facebook app.

Note: Before this step can be performed make sure the HCP application is deployed

For this we need send a post request to /{app-id}/subscriptions as shown below. The verify_token mentioned here should match the verify token mentioned in the local.properties file. If the URL is registered you should see a success message in the response as shown below 

We can also verify the request in the HTTP Access Logs of your application in HANA Cloud platform cockpit. Facebook sends a GET request to the callback_url as a check for subscribing to the URL.

Final step we need to setup the Page Subscribed Apps. For this a Page Access Token is required with publish_pages permission required

That's it. Hope you enjoyed this series and happy learning.

1 Comment