1. Home
  2. Knowledge Base
  3. Facebook
  4. Connect Facebook data with Power BI
  1. Home
  2. Knowledge Base
  3. Microsoft
  4. Power BI
  5. Connect Facebook data with Power BI

Connect Facebook data with Power BI

Integration of Facebook with Power BI

To integrate Facebook data with Power BI, the user must have a Facebook account, the user does not need a special type of account, any Facebook can be used, information about users/pages can be shared. Start our integration process.

Prerequisites

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

-Facebook account

-Power BI desktop

Creation of Facebook apps and disclosure of the API

To integrate the user, the developer must log in to Facebook with user credentials. Open the Facebook for developers. After opening the link, you will be taken directly to this page, the user can log in to their account or click on “Get started”. (Recommended)

If you click on ” First steps “, the user will be redirected to the following page

If you log in with a Facebook account when you have enabled two-factor authentication or other authentication for your account, the user may be asked to verify this.
After the user has completed the login (after all authentications have been completed). You will be redirected to the following page
This is the main menu page, various options are available on this page, users can report problems with the profile (personal account), report errors, view and manage various APIs, for this session, the user is guided to access the profile and page information.
To access it, the user must have completed a simple step, navigate to the top menu bar and select tools> Graph API Explorer, “Facebook Graph API Explorer is a simple Facebook app that allows you to browse the JSON data provided by Facebook Graph API -requests are returned.”
With the Graph API, you can make a json request to Facebook that allows the user to browse data. When you click on Graph API Explorer, the user is redirected to the following page where the user has created an app. This app is used to access the profile/page content.
When the user clicks on the Create app button, they are redirected to where they can create new apps and view apps that have already been created. A user can have more than one app that serves different purposes. This app is not accessible to anyone other than the user.
When clicking on “Create app”, the user is redirected to a page where the user can select the app type. There are different types of apps, each of which fulfills its own purpose. Detailed information on the app type is available here. The transaction type is currently used. If you click on the Next button, the user must enter the display name.
If you click on Create app, the user must enter login information (only one password). The user name and profile picture are visible on the pop-up (they are hidden in the picture).
After the APP has been created, the user is redirected to the following page with the app name, ID and other similar information. For example, if you want to integrate Instagram with Instagram Graph API, you can select Instagram Graph API, Instagram Graph API is for business accounts only.
Our app is now created, users can access profile/page to access the page, to access the data, navigate to Tools> Graph API Explorer.
The user is redirected to the following page. To access the user information, the user must generate an access token. The access token for user and page is different.

To access information for users (profile)

  1. Generate access token: When you click on Generate access token, a pop-up window opens
2. click on Continue as {Benutzername}, in the next step select the APP, all apps are entered, the user can select the app.
3 The next step is to select the authorization. If the user changes the authorization, the access token must be updated
4. then click on Send. If the authorization settings have been generated correctly, the user can see their name and ID in the format of the JSON key-value pairs. If further information is required, additional parameters must be added. Select the parameter to add in the query or the attribute (marked with 3). If the user cannot access all the information, the authorization is missing, add the authorization and update the access token (if you do not update the token, you will get the error when accessing the data.
To access information for page
To access the information of the Facebook page, the user must follow the same steps as the user for the profile, he just has to select the page
  1. Click on the drop-down main menu and select “Get Page Access Token”.
2. if you select “Get Page Access Token”, a pop-up menu opens for authorization

3. click on Continue as{Username} and a new window will appear. If you click on “Next”, the user will be redirected to a new pop-up window

4. after clicking on “OK”, select “Generate token” and the page name for the menu, as shown in the picture

5. after completing this process, the user can access the page information, the user can enlarge or reduce the field according to the requirements, an example is shown in the attached snapshot

6. users can add and remove authorizations according to requirements and even switch back to the user profile. If a problem occurs, this is most likely due to the authorization set or the access token

Accessing the data in Power BI

The next part is the integration of Power BI, the user must have a Power BI license before connecting the data source, the user needs a valid data source URL.

cURL is generated

To get the URL, click on Get code ” in the menu bar at the bottom. The pop-up menu is displayed. Navigate to the last menu, i.e. “cURL”.

Copy the URL and cut off the leading character from this link to the “https” URL and also remove the character from the end. The URL can look like this

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

The user can even test the URL by pasting it into the browser.

The user contains the access token. So if the user has changed the fields or the authorization, the URL is also changed. After adding the authorization, make sure that the URL is updated. Since we have a valid URL, the next step is to access the data in Power BI Desktop.

Connecting PowerBI Desktop

Open PowerBI Desktop and navigate in the pop-up search for “Web” to “Retrieve data” and click on “Connect”.

A pop-up menu appears, enter the URL and click on “OK”. You do not need to seek an advance as the access key is appended to the URL so that anyone with that URL has access to user data, so the URL must be kept confidential

After this Power Query Editor is opened, you can transform the tables according to your requirements
To save, click on ” Close and apply ” in the action bar.

Dieser Beitrag ist auch verfügbar auf: Deutsch (German)

Was this article helpful?

Related Articles

Submit a Comment

Your email address will not be published. Required fields are marked *

Skip to content