Facebook data integration With powerbi

Integrating Facebook with Power BI

To integrate Facebook data with Power BI,user need to have a Facebook account, user don’t need any special type of account,any Facebook can be used, Information related to user/page can be shared.Let start our integration process.

Prerequisites

Users need a Facebook account and Power BI desktop (Power BI license if want to published the report)

•Facebook Account

•Power BI Desktop

Facebook Apps creation and exposing API

To integrate user need login to Facebook for developer with user credentials. Open the Facebook for developer. After you open the link,you will be direct to this page, usercan login to his account or can click on Get started. (Recommended)

On clicking Get Started user will be redirect to the following page

Login with Facebook account, if you have two factor or anyother authentication enable for your account user may beasked to verify it.
After user have completed the login (after completing all authentication). You will be directed to following page
This is the main menu page, this page has different option available,user can report issue about profile (Personal Account), report bug, manage ads and different API, for this session user will be guided about accessing the profile and page information.
To access this,user have performed simple step, navigate to top menu bar, select tools>Graph API Explorer, “The Facebook Graph API Explorer is a simple Facebook app that lets you browse through the JSON data returned by Facebook Graph API requests”
Graph API are you to make json request to Facebook, through this user can explore data. On clicking Graph API Explorer, user will be directed to following page, where user have created an app, this app will be used for accessing the profile/page content.
When user will click on Create App button, he will be redirected to where he can create new apps and view already created apps, one user can have more then one app serving different purposes. These app will not be accessible to anyone else except user.
On clicking Create App user will be redirected to page, where user the select the app type, there are different type of apps, each one serving its own purpose, detail information of apps type is available here. For now, Business type isused, on clicking Next button,user have to provide display name.
On clicking Create App, user will be required to provide login credentials (just password). On popup user name and profile picture will be visible (in the picture these are covered).
After the APP is create user will be directed to below page, with app name, id, and other similar information. For example, if you want to integrate Instagram with can select Instagram graph API, Instagram graph API are only for business account.
Our app in now created, user can access profile/page, to access page, to access the data navigate to Tools> Graph API Explorer.
User will direct to following page. To access the user information,user have to generate Access token, Access token for user and page is different.

To access information for User (Profile)

  1. Generate access token, on clicking Generate access Token, a popup window will be open
2. Click on Continue as {User Name}, next step is to select the APP, all apps will be enlisted, user can select the app.
3. Next step is to select permission, if user change the permission then Access token needs to be refreshed
4. After this click Submit, if the permission setup is generated properly then user can see his name and id in json key value pairs format, if more information is required then add more parameters are required the add parameter in query or select the attribute (marked with 3).If user is not able to access all the information, then this is missing permission, add the permission and refresh access Token (if you don’tn refresh the token then you will get the error in access the data.
To access information for Page
To access Facebook page information user,have to followthe same steps as user did for profile just have to select the page
  1. Click on the main dropped down menu and select the “Get Page Access Token”
2. On select “Get Page Access Token” a popup menu will open for permission

3. Click on Continue as {Username} and new window will appear, clicking “Next” user will be directed to new popup window

4. After clicking okay, “Generate the Token”and select page name for menu as shown in picture

5. After completing this user can access the page information, user can increase or decrease field according to the requirements, one example is shown in the attached snapshot

6. User can add and remove permission according to the requirements,even can switch back to User profile. If facing any issue, most probably will be due to permission set or access token

AccessingtheData in Power BI

Next part is how to integrate Power BI, user must have Power BI license, before connecting the data source user need a valid data source URL.

Generating graph URL

To get the URL click on “Get Code” in the menu bar at the bottom, I popup menu will appear, navigate to the last menu i.e “cURL”

Copy the URL and trim the leading character from this link till “https”URL and remove the character from the end as well. URL may look like this

https://graph.facebook.com/v13.0/me?fields=id%2Cname%2Cposts%7Breactions%7D%2Clikes%2Cfan_count&access_token=EAAJCuvS8ZA7EBAICZCTsI8yelOcp5bWsAtvCpMZB9u2FNY3Wo84Dj7jmIuuCxUHtXzbrj36nw4qRXEEwrKLUtYT1ZBFDfX5KOEgjmQkz3kupxakPaekqoTQlgOF128s2gQsZD

User can even test the URL buy pasting it in the browser.

The user contains the access token, so if user have changed the fields or permission then URL will be changed as well, so after adding permission make sure that URL is refreshed.As we have valid URL next step is to access the data in Power BI desktop.

Connecting PowerBI Desktop

Open PowerBI desktop and navigate to “Get data” in the pop-up search for web and click connect

A popup menu will appear, enter the URL and click “OK”. Don’t need to go for advance as well access key is appending in the URL, so anyone with this URL will have access to user data, so URL need to be kept confidential

After this Power Query editor will be opened, you can transform the tables according to your requirements
Click on “Close and Apply” in the action bar to save.

Was this article helpful?

Related Articles

Werbung