Skip to Content

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

/wp-content/uploads/2015/05/apptoken_707663.png

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)

/wp-content/uploads/2015/05/pagetoken_707662.png

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}

  pagetoken - 2.png
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 

/wp-content/uploads/2015/05/rtsub_707660.png

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.

/wp-content/uploads/2015/05/httploghcp_707659.png

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

/wp-content/uploads/2015/05/subscribeapp_707658.png

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

To report this post you need to login first.

Be the first to leave a comment

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

Leave a Reply