Meta Platforms, Inc., doing business as Meta and formerly Facebook, Inc., is an American multinational technology conglomerate holding company based in Menlo Park, California. The company is the parent organization of Facebook, Instagram, and WhatsApp, among other subsidiaries.
Step 1 : Create an app in facebook from : https://developers.facebook.com/apps/
Step 2 : Copy your Facebook Page ID
Step 3 : Generate Access Token from : https://developers.facebook.com/tools/explorer/ and copy
Step 4 : Extend Acess Token time https://developers.facebook.com/tools/debug/accesstoken/?access_token=your_access_token
Step 5 : copy Acess Token
Step 6 : Paste PageID and AcessToken in script file
Step 7 : Run index.html and done.
Facebook Post
Bimash Maharjan
Followers (0)
.hero {
padding: 6.25rem 0px !important;
margin: 0px !important;
}
.media {
display: -ms-flexbox;
display: flex;
-ms-flex-align: start;
align-items: flex-start;
}
.img-fluid{
width: 48px !important;
height: 48px !important;
padding: 2px;
border: 2px solid #f4f4f4;
}
.media-body {
-ms-flex: 1;
flex: 1;
padding: .4rem !important;
}
.media-body p{
font-family: 'Rokkitt', serif;
font-weight: 500 !important;
font-size: 14px;
color: #88898a;
}
.media-body small span{
font-family: 'Rokkitt', serif;
font-size: 12px;
color: #aaa;
margin-right: 10px;
}
.img-responsive{
display: block;
max-width: 100%;
height: auto;
}
.head{
display: flex;
}
.head>h3{
flex-grow: 1;
}
var posts = document.getElementById('post');
var accesstoken =`YOUR ACCESS TOKEN` ;
var pageid = `YOUR API`;
let facebook = () =>{
fetch(`https://graph.facebook.com/v12.0/${pageid}?fields=posts%7Bid%2Cfull_picture%2Cmessage%2Ccreated_time%7D%2Cfollowers_count%2Cname%2Clikes%2Cpicture&access_token=${accesstoken}`)
.then(response =>{
return response.json()
})
.then (data =>{
var lenght = data['posts'].data.length;
//time ago
const epochs = [
['year', 31536000],
['month', 2592000],
['day' , 86400],
['hour', 3600],
['minute', 60],
['second',1]
];
const getDuration = (timeAgoInSeconds) =>{
for(let [name , seconds] of epochs){
const interval = Math.floor(timeAgoInSeconds / seconds);
if(interval >=1 ){
return{
interval : interval,
epoch : name
};
}
}
};
const timeAgo = (date) =>{
const timeAgoInSeconds = Math.floor((new Date()- new Date(date))/1000);
const{interval , epoch} = getDuration(timeAgoInSeconds);
const suffix = interval == 1 ?'' : 's';
return `${interval} ${epoch}${suffix} ago`;
}
//follower counts
document.getElementById('folow').innerHTML = data.followers_count;
//page name
document.getElementById('pagename').innerHTML = data.name;
//post
for(i=0;i '+data.name+'
'+timeAgo(data["posts"].data[i].created_time)+' '+messages+'