Facebook Graph API

Facebook Graph API

Facebook Graph API is the way to write and read from facebook social graph.It’s the way,we can access /retrieve Facebook data.Facebook Graph API often releases the API versions incremental.Incremental releases to ensure that facebook data is protected.It also provide better user experience.

There are two types of API available in Graph API.

  1. Public API key
  2. Private API key

Public API key allows the user to retrieve information from the publicly available data.Private API key allows the user to get most of the information from the facebook App. We need to understand the importance of public and private access tokens .

When you connect with Facebook through Graph API,it takes you to Graph API Explorer.You have to login in Facebook to get the Access toke.

Select all the permissions required from the Graph API like following

Facebook Graph API
Facebook Graph API

Once,you get the necessary permissions from the access tokens ,you are allowed to read and write in Facebook Social Graph.

You can access the Graph API explorer and enter the following query for example:

The above code will get you the id and name of the facebook user.

Likewise,you can change the query and get different details age,gender,location etc(Provided you have enough permission in the app)

you can find detailed information on following link:Graph API reference API manual

https://developers.facebook.com/docs/graph-api/reference

Each of the object is clearly explained.For simplicity purpose,I will explain object called Post.This is mostly used to retrieve the data from facebook fanpages.

In Graph API Version 2.2,it was easy to retrieve all the feed/post data with single query like select * type. Example: “https://graph.facebook.com/v2.8/microsoftbi/posts” will fetch all the feed/post column,which were 27 in total.

In Facebook API Version 2.9/2.11,facebook doesn’t allow the column to be explicitly visible.we need to query all the columns like below in V2.11.Though its additional effort for developer,for facebook pages -It’s additional layer of protection

Facebook.Graph(“https://graph.facebook.com/v2.8/microsoftbi/posts?fields=id,
admin_creator,
application,
call_to_action,
caption,
created_time,
description,
feed_targeting,
from,
icon,
instagram_eligibility,
is_hidden,
is_instagram_eligible,
is_published,
link,
message,
message_tags,
name,
object_id,
parent_id,
permalink_url,
picture,
place,
privacy,
properties,
shares,
source,
status_type,
story,
story_tags,
targeting,
to,
type,
updated_time,
with_tags&limit=100

The above query will expose listed column above.Please keep in mind that ,you have to explicitly mention all the columns in the Graph API explorer!

Back to http://www.freesocialanalytics.com/how-to-extract-facebook-data-from-powerbi/

 

 

Post Author: Ruchi

Leave a Reply