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




An API is an interface to interact with a service. https://youtu.be/KLe2lCEy-Xw, 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 JSONJavaScript Object Notation is abbreviated to JSON. JSON is independent of the programming language and is compact. We use JSON code to format SharePoint online: Show search results data returned by Facebook Graph API requests”









To access information for User (Profile)
- Generate access token, on clicking Generate access Token, a popup window will be open

3. Next step is to select permission, if user change the permission then Access token needs to be refreshed


To access Facebook page information user,have to followthe same steps as user did for profile just have to select the page
- Click on the main dropped down menu and select the “Get Page Access Token”



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 URLA Uniform Resource Locator identifies and locates a resource, for example a website, via the access method to be used and the location of the resource in computer networks..
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


