Facebook graph api , I learned out to do something called Facebook graphing.
What is Facebook graphing?
Facebook graphing is a technique by which you can collect your Facebook data and display it on your website. The Facebook data can be taken from any page in your Facebook profile or your timeline posts. There are certain limitations to it which we will see further.
To understand even much better we will take a look at how it works.
So now it’s very crucial here to follow each of the above steps mentioned here.
Steps involved:
We will be following the below-mentioned steps one by one :
1.Before Facebook graphing, you need to set up your Gmail id or any email id. This particular mail id will be used to make a business account on Facebook.
2. Next, you need to make a Business account with the above mail id . You can ignore the above-mentioned steps if you already have a Facebook account and you want to display the content from the profile id which you already have.
Log in with your credentials and then click on the login button, this will redirect you again to Facebook developer page i.e https://developers.facebook.com/
Now, you can see My Apps link which is present at the right topmost corner of the page .
A dropdown like an icon will appear, so now you need to hover your mouse to that provided dropdown icon present before MY Apps link.
First:
On the first pop up,give the name of your application and then click on ‘Create App ID’
Second:
Next pop up appears after clicking on ‘Create App ID’ which is a security check.Here you need to verify and submit.
After the successful creation of the application, the screen looks like below pic.
5. Turn it on:
a. The page appears to be the same once you go into Basic settings.
b. To turn it on you need to fill some details asked for.
Required details need to be added:
Privacy Policy URL: https://www.freeprivacypolicy.com/privacy/view/59405ddc8**1b0ee
Checking the radio button for ‘Support my own business’.
Choosing the category from list ‘Business and Pages’.
Now click on ‘save changes’ to save all your basic settings.
Now click on the switch button present on the page to turn it on.
1.Click on the tools and then above like screen will be opened.
2.Now click on the Graph API Explorer which will redirect you to a next screen i.e ‘https://developers.facebook.com/tools/explorer/’
1.The screen for Graph Explorer looks as shown in the pic.
2.Now click on the Get Token button with a dropdown symbol.
3. Within the list, choose ‘Get User Access Token’ and click on it which will take you to the pop-up screen.
Extending the token life periods.
Thus you got the lifetime key you got, which will be used to get the specific page post in JSON format.
Facebook graphing is done.
Now, To collect the data from the generated token you can use ajax call to retrieve the data from Facebook API.
Below is the sample jquery ajax call to retrieve the data.
$.ajax({
cache: false,
type: "GET",
contentType: JSON,
url: 'https://graph.facebook.com/v3.1/me?fields=posts&access_token=' + token,
success: function (res) {
// console.log(res);
var counter = 0;
var response = [];
response = res.posts.data;
//var statichtml = '<div class="news-and-announcements tab-anchor-content section-margin-top-50">'+'<div class="container">'
//'<div class="section--hdr">' + ' <h2 class="second-hdr-underline">Social</h2>' +'</div>' + ' <div class="row">';
for (var i = 0 ; i < response.length ; i++) {
// if (response[i].story == undefined) {
if (counter < 3) {
//var dates = new Date(Date.parse(response[i].created_time, "MM/dd/yyyy"));
//var date = dates.toString().substring(0, 15);
//var htmlelement = ' <div class="col-md-4">' + '<h5>' + date.substring(0, 15) + '</h5>' +
// '<p>' + response[i].message.substring(0,250) + '</p>' + '</div>'
var d = new Date(response[i].created_time);
if (response[i].message != undefined && response[i].message != "" && response[i].message != null) {
var msg = response[i].message;
if (msg.length > 250) { msg = msg.substring(0, 249) + '...'; }
var htmlelement = ' <div class="col-md-4">' + '<h5>' + response[i].created_time.toString().substring(0, 10) + '</h5>' + '<p>' + msg + '</p>' + '</div>'
$('#socialfeed').append(htmlelement);
counter = counter + 1;
}
}
// }
}
},
error: function () {
//alert('error');
$('.socialFeed').hide();
},
complete: function (res) {
}
})
}
URL: ‘https://graph.facebook.com/v3.1/me?fields=posts&access_token=’ + token,
token =Here, you need to keep your generated token.
So, It’s done. Let me know if you encountered any problem in any section. This is called Facebook graphing.
1. The generated token expires in 60 days
2. If it shows the alert as an error, it means either the token is not valid for getting the specific page posts.
You can visit https://developers.facebook.com/docs/graph-api/ to learn more the contents about Facebook graph api .
Thank you.
When it comes to security services in Noida, there are several reputable companies that cater to various needs. Let me…
Are you tired of dealing with tooth decay, gum problems, and expensive dental treatments? Look no further! Steel Bite Pro…
In the world of fine jewelry, oval moissanite rings have emerged as a captivating choice for those seeking elegance and…
Noida, located in the state of Uttar Pradesh, is a fast-growing hub of digital marketing agencies in India. Choosing the…
As we move into 2023, the world of motorcycles in India is set to see some exciting changes. Manufacturers are…
The Indian Premier League (IPL) is one of the most popular and exciting cricket tournaments in the world. With the…
Leave a Comment