• Blog
  • Contact
  • Sign in
CloverDX
Product
  • Overview
  • CloverDX Data Integration Platform
  • What's new in CloverDX 6
  • Pricing
  • CloverDX plans
  • Deployment
  • CloverDX on AWS
  • CloverDX on Azure
  • CloverDX on Google Cloud
  • CloverDX on-premise
  • Resources
  • Customer Portal
  • Documentation
  • Downloads & Licenses
  • Webinars
  • Academy & Training
  • Release Notes
  • CloverDX Forum
  • CloverDX Blog
  • Tech Blog
  • Other resources
isometric-illustration--product@2x 1

Get under the hood of CloverDX

See how CloverDX can benefit your business with a live demo. Simply get in touch with our team and we’ll handle the rest.

Book a demo
Solutions
  • By Industry
  • Banking
  • Capital Markets
  • Consultancy & Advisory
  • FinTech
  • Government Agencies
  • Healthcare
  • By Use Case
  • Data Quality
  • Data Ingest
  • Data Warehousing
  • Data Migration
  • Digital Transformation
  • Enterprise Data Management
  • Risk & Compliance
  • Anonymization
How F3 Group use CloverDX to ingest more client data - webinar
Customer interview

Formula 3: Staying Small And Agile While Working With Large Enterprise Ecosystems

Browse webinars
Services
  • Services
  • Onboarding & Training
  • Professional Services
  • Customer Support

More efficient, streamlined data feeds

Discover how Gain Theory automated their data ingestion and improved collaboration, productivity and time-to-delivery thanks to CloverDX.

 

Read case study
Customers
  • By Use Case
  • Analytics and BI
  • Data Ingest
  • Data Integration
  • Data Migration
  • Data Quality
  • Data Warehousing
  • Digital Transformation
  • By Industry
  • App & Platform Providers
  • Banking
  • Capital Markets
  • Consultancy & Advisory
  • E-Commerce
  • FinTech
  • Government
  • Healthcare
  • Logistics
  • Manufacturing
  • Retail
Migrating data to Workday - case study
Case study

Effectively Migrating Legacy Data Into Workday

Read customer story
Company
  • About CloverDX
  • Our story & leadership
  • Contact us
  • Partners
  • CloverDX Partners
  • Become a partner
Pricing
Demo
Trial

CloverDX and Facebook Graph API: What You Need to Know

API CloverDX How-To
Posted March 11, 2014
2 min read
CloverDX and Facebook Graph API: What You Need to Know

Today we'll tackle how to utilize CloverDX with Facebook. Facebook Graph API allows applications to access social graphs. This blog post describes how to use Graph API within CloverDX.

What is Facebook Graph API?

The Facebook Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

Querying Facebook via Graph API consist of two steps:

  1. Generate an access token using App ID and App Secret
  2. Use the access token to invoke API calls

We’ll use App Access Token, as it doesn’t require user interaction during the generation process and does not expire. Check out the documentation to see the differences between available tokens and their limitations. For example App Access Token does not allow to use "me" as userId or search queries are limited to Page and Place type only.

Register the Facebook App

Let’s get to it. First, you need to register the Facebook app. Note that you have to be a verified Facebook user to be able to register the application. Go to https://developers.facebook.com/apps and register a new application there.

CloverDX and Facebook Graph API

After registering your application, you’ll see App ID and App Secret in the application dashboard. You’ll need these two values in the CloverDX graph.

CloverDX and Facebook Graph API

CloverDX and Facebook

Now we can proceed to CloverDX. This example graph retrieves Facebook friends and stores them in an XML file in alphabetical order.

CloverDX and Facebook Graph API

It uses the HTTPConnector component to retrieve the access token. The query URL is https://graph.facebook.com/oauth/access_token. App ID and App Secret are used as HTTP request parameters.

The access token query in the example is:

https://graph.facebook.com/oauth/access_token?client_id=${APP_ID}&client_secret=${APP_SECRET}&grant_type=client_credentials

The response content is:

access_token=702578739774856|B0HwJl3tIFM4ShwBXHEuyB3rB20

The access token is parsed using the Reformat component and its value is passed to the next HTTPConnector where it’s used as a query parameter. The query URL is https://graph.facebook.com/{user_id}/friends – this time with the access_token request parameter. This is a regular Graph API call. See the Graph API documentation for other available methods.

An example query API call:

https://graph.facebook.com/${USER_ID}/friends?access_token=702578739774856%7CB0HwJl3tIFM4ShwBXHEuyB3rB20

Response JSON is parsed using the JSONExtract component and one more HTTP request (https://graph.facebook.com/{user_id}) is performed for each result (=each friend). This query retrieves detailed information about the friend.

The JSONExtract mapping is very simple because it uses automapping by field names. Mapping used in JSONExtract:

<Mappings>
<Mapping element="json_object" outPort="0">
</Mapping>
</Mappings>

The final part of the graph just sorts detailed info about friends using the ExtSort component and writes them into an XML file using XMLWriter. The XML writer uses this mapping:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:clover="http://www.CloverDX.com/ns/xmlmapping">
<clover:element clover:name="facebook_item" clover:inPort="0">
<clover:element clover:name="first_name">$0.first_name</clover:element>
<clover:element clover:name="last_name">$0.last_name</clover:element>
<link>$0.link</link>
<username>$0.username</username>
</clover:element>
</root>

to produce XML like this (real values are replaced by “...” - I do not want to show my friend’s names here):

<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<facebook_item>
<first_name>...</first_name>
<last_name>...</last_name>
<link>http://www.facebook.com/...</link>
<username>...</username>
</facebook_item>
<facebook_item>
<first_name>...</first_name>
<last_name>...</last_name>
<link>http://www.facebook.com/...</link>
<username>...</username>
</facebook_item>
…
</root>

Download the example

Connecting to Facebook using CloverDX - Example

Share

Facebook icon Twitter icon LinkedIn icon Email icon
Try CloverDX for 45 days  Full access to Tech Support as if you were a customer

Newsletter

Subscribe

Join 54,000+ data-minded IT professionals. Get regular updates from the CloverDX blog. No spam. Unsubscribe anytime.

Related articles

Back to all articles
The importance of API services in today's integrations
API
4 min read

The importance of API services in today's integrations

Continue reading
CloverDX 101 - some basic concepts explained
CloverDX How-To
7 min read

CloverDX 101: Some basic concepts explained

Continue reading
Building APIs and user interfaces for your data workloads
API CloverDX
5 min read

Building APIs and user interfaces for your data workloads

Continue reading
CloverDX logo
Book a demo
Get the free trial
  • Company
  • Our story
  • Contact
  • Partners
  • Our partners
  • Become a partner
  • Product
  • Platform overview
  • Plans & Pricing
  • Customers
  • By Use Case
  • By Industry
  • Deployment
  • On-premise
  • AWS
  • Azure
  • Google Cloud
  • Services
  • Onboarding & Training
  • Professional Services
  • CloverCARE Support
  • Resources
  • Customer Portal
  • Documentation
  • Downloads & Licenses
  • Webinars
  • Academy & Training
  • Release Notes
  • CloverDX Forum
  • CloverDX Blog
  • Tech Blog
  • Other resources
Blog
Why data accessibility is essential for your digital transformation
Data Integration
4 barriers to making data-driven decisions
Data Strategy
4 steps to providing a data-driven customer experience
Data Integration
Implementing data democratization: 3 ways to make your data more accessible
Data Innovation
© 2023 CloverDX. All rights reserved.
  • info@cloverdx.com
  • sales@cloverdx.com
  • ●
  • Legal
  • Privacy Policy
  • Cookie Policy
  • EULA
  • Support Policy