How to display Facebook page posts on website using PHP?

display-facebook-feed-on-website

In this tutorial, I will show you how to display Facebook page posts on website using PHP.

Posts from your Facebook page are not shown to your website visitors. You spend a lot of time creating, editing, and managing your posts. But your fans, audience, and customers from your website still do not see your Facebook posts.

Our code in this tutorial will allow you to automatically display your Facebook page posts on your website using PHP. Create and edit your posts on Facebook and any changes will also be reflected on your website.

Overview

Our code for today will get any type of post like videos, statuses, or pictures from your Facebook page using Facebook Graph API.

We will display these posts or contents to a webpage (assuming it is your website) beautifully with Bootstrap.

If you’re not yet familiar with this awesome front-end framework, see our step-by-step Bootstrap tutorial here. It is also responsive so it’s one advantage for mobile devices.

Don’t want to code?

Before we continue coding, if you later realized you do not want to code and you need more features, you can use a website plugin called SociableKIT. It is the best no-code tool for the job.

You can easily customize the look and feel of your Facebook feed and embed it on your website in 3 minutes. The posts feed on your website will update automatically.

Follow this tutorial: Embed Facebook page posts on website. You can also embed other types of feeds such as the Facebook page events, photos, videos, and more. There’s a free plan that you can use if you don’t need the premium features of SociableKIT.

But if you like coding, continue with our tutorial below!

Code Output

It is important to know where we are going. Once we finished the tutorial, we will achieve the output in the video below.

Enjoy the step-by-step tutorial below!

Create the index page

Create index.php file with basic HTML code

This index file will be loaded first and what we will see on the browser. Create index.php file. Put the following code.

<!DOCTYPE html>
<html lang="en">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Display Facebook page posts on website</title>

    <!-- CSS will be here -->

</head>
<body>
    <!-- Facebook page posts will be here -->
    <!-- JavaScript will be here -->
</body>
</html>

Include Bootstrap and custom CSS

Here we include Bootstrap CSS and our own custom CSS to make our page look good. Replace <!– CSS will be here –> comment with the following code.

<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="custom.css" media="screen">

Include JavaScript

Include Bootstrap and Font Awesome JavaScript. Bootstrap JavaScript is required for Bootstrap to work better. We use Font Awesome for the likes and comments count icons. Replace <!– JavaScript will be here –> comment with the following code.

<!-- JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://kit.fontawesome.com/dd3a1aa24e.js" crossorigin="anonymous"></script>

Put code for Facebook page posts

Here’s the body of our webpage. In this part, we will display the Facebook page posts. Replace <!– Facebook page posts will be here –> comment with the following code.

<div class="container">
	<div class='col-lg-12'>
		<h1 class='page-header'>Display Facebook page posts on website</h1>
		
		<?php include "facebook_page_posts.php"; ?>

	</div>
</div>

Custom CSS

Create custom.css file

Create a custom.css file. This file was used inside the index.php file. Put the following code.

/* profile css will be here */

/* post css will be here */

/* other css will be here */

Profile CSS

The following CSS code is intended for profile information on the page. Replace /* profile css will be here */ comment with the following code.

.profile-info{
    overflow:hidden;
}

.profile-photo{
    float:left;
    margin:0 .5em 0 0;
}

.profile-photo img{
    width:40px; height:40px;
}

.profile-name{
    float:left;
    width:85%;
}

.profile-message{
    margin:1em 0;
}

Post CSS

The following CSS code is for post information on the page. Replace /* post css will be here */ comment with the following code.

.post-link{
    text-decoration:none;
}

.post-content{
    background: #f6f7f9; overflow:hidden;
}

.post-content img{
    width:100%;
}

.post-status{
    margin:.5em; font-weight:bold;
}

.post-picture{
    width:25%; float:left;
}

.post-info{
    width:70%; float:left; margin:.5em;
}

.post-info-name{
    font-weight:bold;
}

.post-info-description{
    color:#999;
}

Other CSS

These are other CSS codes used to make our web page look good. Replace /* other css will be here */ comment with the following code.

.page-header{
    margin:50px 0;
}

.time-ago{
    color:#999;
}

.like-count-summary{
    margin-top:10px;
}

Display Facebook page posts

Create facebook_page_posts.php file

This file will be used to be the central place where the Facebook page posts feed will be requested (from the Facebook Graph API), processed, and displayed. Create a facebook_page_posts.php file. This file was also used inside the index.php file. Put the following code.

<?php
include "functions.php";

// parameters will be here

// json link and contents will be here

// posts loop will be here
?>

Create functions.php

We have one function in this file. Its purpose is to convert a date and time value to a “time ago” format. For example 1 day ago, 2 hours ago, 1 month ago, etc. Create functions.php file. This file was used inside the facebook_page_posts.php file. Put the following code.

<?php
// to get 'time ago' text
function time_elapsed_string($datetime, $full = false) {

	$now = new DateTime;
	$ago = new DateTime($datetime);
	$diff = $now->diff($ago);

	$diff->w = floor($diff->d / 7);
	$diff->d -= $diff->w * 7;

	$string = array(
		'y' => 'year',
		'm' => 'month',
		'w' => 'week',
		'd' => 'day',
		'h' => 'hour',
		'i' => 'minute',
		's' => 'second',
	);
	foreach ($string as $k => &$v) {
		if ($diff->$k) {
			$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
		} else {
			unset($string[$k]);
		}
	}

	if (!$full) $string = array_slice($string, 0, 1);
	return $string ? implode(', ', $string) . ' ago' : 'just now';
}
?>

Parameters

These variables contains the parameters needed to make a request to the Facebook graph API. Replace // parameters will be here comment with the following code.

// prepare parameters
$fb_page_id = "YOUR_PAGE_ID";
$api_version = "v11.0";
$profile_photo_src = "https://graph.facebook.com/{$api_version}/{$fb_page_id}/picture?type=square";
$access_token = "YOUR_PAGE_ACCESS_TOKEN";
$fields = "id,attachments,message,picture,icon,created_time,from,story,likes.limit(0).summary(true),comments.limit(0).summary(true)";
$limit = 30;

Specify your Facebook page ID and token

You need to replace YOUR_PAGE_ID and YOUR_PAGE_ACCESS_TOKEN with your own. There are two ways to retrieve your page ID and token.

The first method is this: To get your Facebook page ID, follow this tutorial. To get your Facebook page access token, follow this tutorial. This method can be time-consuming.

We can do this process for you but there will be a service fee of $50. Also, you will need to make us an admin of your Facebook page. If you want to avail of this service, pay using this link. After the payment, you will receive further instructions from [email protected]

The second method this: We built and maintain a tool where you can easily retrieve your page ID and token. It costs $30. You can buy an access here. This method is faster and easier.

JSON link and contents

In this part, we will build the whole request link and get the response from the API. Replace // json link and contents will be here comment with the following code.

// build json link and get contents
$json_link = "https://graph.facebook.com/{$fb_page_id}/posts?fields={$fields}&limit={$limit}&access_token={$access_token}";
$json = file_get_contents($json_link);
$obj = json_decode($json, true);
$feed_item_count = count($obj['data']);

Loop through posts

Once we got the response or the data from the API, we will loop through it this way. Each loop contains a Facebook post from your page. Replace // posts loop will be here comment with the following code.

// loop throug posts
foreach($obj['data'] as $post){
    include "extract_values.php";
    include "display_values.php";
}

Extract values

Create extract_values.php file

Create extract_values.php file. This file was used inside facebook_page_posts.php file. Put the following code.

// post id, link, and page name will be here

// when it was posted will be here

// attachments will be here

// message and story will be here

// likes and comments count will be here

Extract post ID, link and page name

In this code, we will get the post ID and page name. We will also build the link to the original post on Facebook. Replace // post id, link, and page name will be here comment with the following code.

// post id, link, and page name
$id = isset($post['id']) ? $post['id'] : "";
$link = "https://www.facebook.com/{$id}";
$page_name = isset($post['from']['name']) ? $post['from']['name'] : "";

Extract post date

The following code retrieves the post date and time. We convert this value to a “time ago” value. Post date will look like this: 4 weeks ago. 3 days ago, 1 month ago, 2 years ago. We are using the time_elapsed_string() function from functions.php file in this part of the code. Replace // when it was posted will be here comment with the following code.

// when it was posted
$created_time = isset($post['created_time']) ? $post['created_time'] : "";
$converted_date_time = date( 'Y-m-d H:i:s', strtotime($created_time));
$ago_value = time_elapsed_string($converted_date_time);

Extract attachments

We will get the post attachments. Attachments contains the post type, image or thumbnail, post title, and description. These data makes a post look more informative. Replace // attachments will be here comment with the following code.

// attachments
$att_type = "";
$att_title = "";
$att_description = "";
$att_image = "";
if(isset($post['attachments'])){
    $att_type = isset($post['attachments']['data'][0]['type']) 
        ? $post['attachments']['data'][0]['type'] : "";

    $att_title = isset($post['attachments']['data'][0]['title'])
        ? $post['attachments']['data'][0]['title'] : "";

    $att_description = isset($post['attachments']['data'][0]['description'])
        ? $post['attachments']['data'][0]['description'] : "";

    $att_image = isset($post['attachments']['data'][0]['media']['image']['src'])
        ? $post['attachments']['data'][0]['media']['image']['src'] : "";
}

Extract message and story

The $message variable contains the custom text entered by the user for the post. The $story variable contains values such as “added an even” or “updated their status”. Replace // message and story will be here comment with the following code.

// message and story ("updated their status." or "added an event")
$message=isset($post['message']) ? $post['message'] : "";
$message=htmlspecialchars_decode(str_replace("\n", "<br>", $message));

$story = isset($post['story']) ? $post['story'] : "";

Extract likes and comments count

The likes and comments count are important signals of engagement. The following code is how we get these values. Replace // likes and comments count will be here comment with the following code.

// likes and comments count
$likes_count=isset($post['likes']['summary']['total_count'])
    ? $post['likes']['summary']['total_count'] : 0;

$comments_count=isset($post['comments']['summary']['total_count'])
    ? $post['comments']['summary']['total_count'] : 0;

Display values

Create display_values.php file

This file was also used inside facebook_page_posts.php file. Create display_values.php file. Put the following code.

<?php 
echo "<div class='item_box'>
    <div class='row'>";

        <!-- left side of the post will be here -->
        <!-- right side of the post will be here -->

    echo "</div>
    <hr />
</div>";

Display profile photo, story, post date, and message

The following code will display the page’s profile photo, page name, date posted, and message. All on the right side of the post. Replace <! — left side of the post will be here –> comment with the following code.

// left side
echo "<div class='col-md-4'>
    <div class='profile-info'>
    
        <div class='profile-photo'>
            <a href='https://fb.com/{$fb_page_id}' target='_blank'>
                <img src='{$profile_photo_src}' />
            </a>
        </div>

        <div class='profile-name'>
            <div>";
                echo !empty($story) ? $story : $page_name;
            echo "</div>
            <div class='time-ago'>{$ago_value}</div>
        </div>
    </div>

    <p class='profile-message'>
        {$message}
    </p>
</div>";

Display attachments, likes, and comments count

The following code will display the attachment image, title, and description on the right side of the post. There is a link to the post on Facebook. It will also display the likes and comments count. Replace <! — right side of the post will be here –> comment with the following code.

// right side
echo "<div class='col-md-8'>
    <a href='{$link}' target='_blank' class='post-link'>
        <div class='post-content'>";

                if($att_image){
                    echo "<div class='post-picture'>
                        <img src='{$att_image}' />
                    </div>";
                }

                else{
                    echo "<div class='post-status'>
                        View on Facebook
                    </div>";
                }

                // if there's an attached title and description
                if($att_title && $att_description){
                    echo "<div class='post-info'>
                        <div class='post-info-name'>{$att_title}</div>
                        <div class='post-info-description'>{$att_description}</div>
                    </div>";
                }
            
        echo "</div>
    </a>

    <div class='like-count-summary'>
        <div style='float:left; margin:0 .6em 0 0;'>
            <i class='far fa-thumbs-up'></i> {$likes_count}
        </div>
        <div style='float:left;'>
            <i class='far fa-comments'></i> {$comments_count}
        </div>
    </div>
</div>"; 

What People Say About This Code?

I’m so glad that other people are delighted by this code, here are some of them!

★★★★★ “This guy is the best. There was a small issue and he helped right away. I recommend this script to everybody. Instead of wasting time by copy-pasting, just purchased the package and saved a lot of time also it came with many ajax features.” ~ Aykun

★★★★★ “BIG THANKS! I’ve been searching and messing around with SDK, Composer, FB APIs… to achieve to place feeds in my FB page to appear on my website without any luck until now.” ~ Hip

★★★★★ “Hi there Mr. Ninja, thanks for that guide and your effort. It is working great after I understood how to use it. :)” ~ Martin Pfeiffer

★★★★★ “Like a boss! You’re awesome! Thanks a lot!” ~ Freddy Moran Jr.

★★★★★ “Thanks for the script!” ~ Omer Rosenbaum

★★★★★ “Thanks a lot. Amazing support. Let me know if there is anywhere that I can write a review.” ~ A. Cetinkaya

Download Source Code

You can get the source code by following the whole, well-detailed tutorial above. But isn’t it more convenient if you can just download the complete source code we used, and play around with it?

There’s a small fee in getting the complete source code, it is small compared to the value or skill upgrade it can bring you, or income you can get from your website project or business.

For a limited time only, I will give you the source code for a low price. Download the source code by clicking the green buy button below.

FEATURES BASIC
Do it once: post on your Facebook page and automatically show it on your website Yes
Save time studying and coding these features on your website Yes
Automatically show type of post, it can be status, link, video, etc. Yes
Posts are linked to your Facebook page. Engage your visitors to your Facebook page. Yes
Status post will have “View On Facebook” link Yes
Posts will show the link thumbnail, title, and description Yes
Shows posted photo Yes
Display number of likes Yes
Display number of comments Yes
Bootstrap UI enabled Yes
Responsive layout (great for mobile devices!) Yes
Show “time ago” of posts Yes
Show like and comment icons Yes
Free email support for 3 months. Yes
Free source code updates. Yes
$50 – Download now

Do you need more reasons to download the source code?

MORE REASONS TO DOWNLOAD THE CODE
One-time payment. No need to buy a subscription. Yes
Buy only once, use on up to 5 websites and Facebook pages! Yes
No different kind of licenses. Yes
No many different pricing schemes. Yes
No monthly or yearly fees. Yes
No need to rely on another website to render Facebook timeline feeds Yes
No need for codes from other websites. Yes
Familiarize yourself with the Facebook Graph API. Yes
Completely customizable. Yes

Need help and support? email [email protected]

Thank you for supporting our projects here at codeofaninja.com!

What’s Next?

Today we have learned how to show your Facebook page posts on your website. Did you know that you can also display Instagram feed on your website?

Let us go to the next tutorial: How to display Facebook page events on website using PHP?

Related Tutorials

We have more tutorials related to social media APIs. Click here.

Some Notes

Found An Issue?


If you found a problem with this code, please send us an email. Before you send an email, please read our our code of conduct. Our team's email address is [email protected]


Please be descriptive about your issue. Please provide the error messages, screenshots (or screen recording) and your test URL. Thanks!


Subscribe to CodeOfaNinja


Receive valuable web development tutorials to your email. Subscribe now for FREE!



Thank You!

Thanks for visiting our tutorial on how to display Facebook page posts on the website using PHP and Facebook Graph API!

By Mike Dalisay

I'm Mike Dalisay, a pro web developer since 2010. I love web development. Improving our tutorials and source codes makes me happy. Do you want to suggest an edit to our tutorial? Got something to ask about our source codes? You may use our comments section below or email our team at [email protected]

90 comments

  1. Hi @disqus_p6iJ2hWqX9, your statement is accurate. It is truly frustrating. Our code above will work but it needs an approve app and correct page access tokens.

  2. Is there a way to change a to an for when you shared events… it says “user has shared a….” but for event should be an

  3. This code is working fine on my xampp local server, but as soon as i run it on my php live server, {post_id} is not tracked down. Can you please help me, its very urgent!

      1. my server has json! and i have no clue how to enable allow_url_fopen? can you help me out with this please!

      2. You can ask your web hosting provider to enable it for you.

        To verify it was enabled, try to create a new “info.php” file, inside this file put:

        phpinfo();

        Make sure it is between php tags. Run that info.php file and post link here.

  4. Looks like a really good script, however I’m having problems getting anything out of Facebook and I wonder if you could help.
    I’m created an App, and I’m using the correct access token (generated as your example) and the correct page ID, and yet all I get from the FB api is an error message :
    “Unsupported get request. Object with ID ‘[PAGE ID]’ does not exist, cannot be loaded due to missing permissions, or does not support this operation. ”
    Do I have to set any permission within the FB page or within the FB app that haven’t been mentioned within the tutorial?

  5. Great script, however I can’t seem to get any data to come out of the Graph API. I imagine I’ve not setup something correctly but all I get is the error below:
    “Object with ID ‘[XXXXCORRECT-FB-OBJ-IDXXX]’ does not exist, cannot be loaded due to missing permissions, or does not support this operation.”
    Do I need to set permissions up in the FB app configuration?
    I’ve looked around a lot, but can’t see anything that makes it obvious.
    Any help greatly appreciated!

  6. Fantastic script and great support. Great to see people sharing there scripts to help those of us just starting out to learn.

  7. I like your website and your tutorials are very useful. Recently, I learn how to get the tweeter’s feed and also the instagram’s one because of you.

    But with the facebook’s feed, strangely when I try to get the JSON content, i have that error :
    (#100) Tried accessing nonexisting field (feed) on node type (Application)

    Do you know why?
    Thanks to answering!
    -Gab

  8. My website doesn’t seem to update the latest news. has the same posts. The time updated doesn’t seem to change either. Weird thing is if i re upload the file it will update but it seems only in chrome. One the browsers it doesn’t update on if there is a video it says wrong mime type.. worked when i frist did it :(

  9. Hi – I’m curious if it is possible with this code (or a few simple changes) to only pull certain posts from the page. For example, so posts are hashtaged “Marketing” and some are hashtaged “Design” and I only want to pull the ones that are hashtaged “Marketing” – BTW – YOU ROCK!

    1. Hello @disqus_MM75W44AQA , thanks for the kind words! About your question, unfortunately our code cannot pull posts by hashtags. I remember it can be done in api version 1.0 before but this feature was gone in 2.0 onwards.

  10. So after six hours I finally solved the problem with other people showing up in your page feed. Simply replace feed with posts:

    “https://graph.facebook.com/{$fb_page_id}/feed?access_token={$access_token}&fields={$fields}&limit={$limit}”;

    “https://graph.facebook.com/{$fb_page_id}/posts?access_token={$access_token}&fields={$fields}&limit={$limit}”;

  11. On my website and your demo the images are nog loading in Firefox. It works perfect in Chrome and Safari. Any idea how to solve this?

    Update: Changed Firefox history setting from ‘Never remember history’ to ‘Remember history’ and now it works!

    1. Hello @disqus_okn1WG3kdy, thanks for reporting the issue and sharing your solution! Would you share your website so we can investigate more about the issue?

      1. Nope sorry, It is on a closed closed development environment. But the demo on this page behaves the same.

      2. Alright, we understand. If it helps, we tested the demo and we are unable to replicate the issue here at our end (with the latest version of Firefox)

  12. Hello @joshmarsteffens, my apologies for the late reply, you should send me an email at [email protected]. Anyway, about your concern, would you tell us your Facebook page link? We will try to replicate your issue and come up with a solution. Please email more details via email.

  13. Hello,

    I have a fiew questions reguarding the Basic source code that i bought from you (witch by the way is AWESOME exactly what i was looking for for a long time.)

    but i have some error’s:

    when i just run your pack without any changes it tells me

    Notice: Undefined index: description in C:xampphtdocstestsfacebook_postsindex.php on line 155

    Notice: Undefined index: object_id in C:xampphtdocstestsfacebook_postsindex.php on line 167

    Notice: Undefined index: comments in C:xampphtdocstestsfacebook_postsindex.php on line 233

    and some more undefined indexes when im changing the page id to the one i want to use.

    next to that the images from the like button and the comments button misses (I checked the link and it returns an emputy page)

    Thanks for all the coding its amazing work!

    -Joshmar

  14. Great tutorial. But I have the problem of missing images also.

    The weird thing is there’s nothing wrong with the code. For instrance I can put ” “https://graph.facebook.com/{$fb_page_id}/picture?type=square” link into the adress bar while changing the “fb_page_id” and I can get to the square profile picture whether I am logged in or not, it doesn’t matter. But when the webpage I am using this on tries to do it, it doesn’t work. I am guessing it’s because of a non-granted permission. I hope someone has a solution for this.

    Thanks in advance.
    -Yanek

      1. Hello @yanekyuk, we are unable to replicate the error you described, our demo links above works fine. Would you send your test URL or a screenshot?

      2. I think the problem is about me. As you can see, external links work just fine. But the ones that are coming from facebook server. Check the image I’ve uploaded.

      3. Nothing wrong the facebook ID or anything. It’s caused by my computer. I wonder why.

      4. I haven’t found what causes it. I simply ignore it for now. If I ever fix it I will write it down here.

  15. This code is amazing. I’m looking for use Facebook API without SDK, then i found this code. but, i have some issue about API. I had trying to open this API link (
    https://graph.facebook.com/141897xxxx/feed?access_token=150970xxxxxxxx&fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&limit=5) in my browser to get some feed in my facebook account, but it only look like this

    {
    “data”: [

    ]
    }

    The “data” shouldn’t empty. Is there any wrong with that link? sorry for bad english

    1. Hello @disqus_wHiZMCQZ8T, thanks for the kind words! About your concern, you cannot get Facebook feed using your personal FB account, this script works only with Facebook pages.

  16. hi there!
    Is this possible to mix this feed with other social networks?

    btw this is really good coding.

  17. Hi, having an issue with the feed displaying content from another user posting on the page, how could I limit the feed to match only the authors ID from $fb_page_id?

    $obj[‘data’][$x][‘from’][‘id’];

    1. Hello @antifaith, thanks for letting us know about this issue, we’re working on it. By the way, would you link us to the FB page you’re trying to use this script with?

      1. https://www.facebook.com/Watersmeethotel1?fref=ts

        $found_post = false;

        for($x=0; $x<$feed_item_count; $x++){

        $fb_author_id = $obj['data'][$x]['from']['id'];

        if ($fb_author_id == $fb_page_id) {

        $found_post = true;

        break;

        }

        }

        if (! $found_post) {

        echo "";

        return;

        }

        Fixed it, though there was then an issue when they posted a link to something that bought up a thumbnail, and now when they've posted a facebook video, there's no fallbacks for not being able to deal with this data

  18. I’m sorry to bother you. I’m new to coding so I thought of asking before diving into this adventure.
    The first part of step 3 seems vague to me and I can’t understand how to “create an app” as you suggest.

    The URL you show leads me to this message:

    {
    “error”: {
    “message”: “An unknown error has occurred.”,
    “type”: “OAuthException”,
    “code”: 1
    }
    }

      1. Thanks. I followed the other article’s guide but now i’m stuck again.

        I followed all your steps and the only thing that i happen to see in my index.php is the page title (I’m testing this in localhost with MAMP).

        I copy pasted everything (and changed the id and the access token) in this page and I can’t understand what’s wrong. :(

      2. Ok. I just accomplished it by trying it on a NetBeans project. By the way, how can i test it locally? I’m trying to put the localhost in the app domain but it seems that it doesn’t work.

      3. I made this script in localhost, I was using WAMP. I think it should also work for you given the right requirements. Recommended is PHP 5.4+ and JSON extension is enabled.

      4. By checking the source code (via browser) I noticed that the entire php code is missing. :

      5. @Wannabe Dev, you won’t see the PHP source code when you try to ‘view source’ in the browser because it is a server side script.

  19. Hey, thank you for the code. It works fine except that I am unable to get pictures exctacted from the links i have posted on the fb page. The images are not displaying on the webpage except for one post which was taken from fb newsroom. How can i get the images to display? please help?

  20. hello. Thanks for the code. works fine except that it wont display any pictures except pictures of posts taken from fb newsroom itself. what do i do for it to display the pictures of posts? The posts are hyperlinks and fb populates the picture by itself from those links.

  21. This guy is the best. There was a small issue and he me helped right away. I recommend this script to everybody. Instead of wasting time by copy pasting, just purchased the package and saved a lot of time also it came with many ajax features.

  22. I just purchased the plugin but I doubles up every post. I Just checked the demo and it looks the same. Is there a solution for this ?

    1. Thanks for purchasing the code! It looks fine now, I think FB is having an API update. That’s why it doesn’t seem to work, but this rarely happens. I’ll send you an email.

  23. This can be useful if you want to add an image in case of the type of publication was a video (for youtube only):

    *add this after the line “if($type==”status”){…….}”.

    else if($type==”video”){

    $parse_vurl = parse_str(parse_url($link,PHP_URL_QUERY), $get_from_var);

    $youtube_vid = $get_from_var[‘v’];

    echo “”;

    }

  24. Hi there, Mr. Ninja.
    Thanks for that guide and your effort. It is working great, after I understood how to use it ^^.
    One question:
    I’m grabbing the whole feed of a public Facebook timeline. There are some posts, who are just shared, so the original post is on another timeline.
    Those are displayed as “XYZ shared a status” and its link “View on Facebook”.
    Is there a way, to display the whole shared status in my feed?

    Regards,
    Tin

    1. Hello @disqus_sTVjGfq9ri, I’m gonna add that feature in the future update of this code, thanks a lot for you suggestion!

    1. Hello you guys, you can try to do it like this:

      $picture_url = urldecode(isset($picture_url_arr[1]) ? $picture_url_arr[1] : “”);
      $name = isset($obj[‘data’][$x][‘name’]) ? $obj[‘data’][$x][‘name’] : “”;
      $description = isset($obj[‘data’][$x][‘description’]) ? $obj[‘data’][$x][‘description’] : “”;

  25. Sorry for the late reply, the Notice: Undefined means there’s no value on the variable you’re trying to access. You can try to use the isset() function to check if a variable has value.

  26. Hi. First of all: BIG THANX

    I’ve been searching and messing around with SDK, Composer, FB APIs,.. to achieve to place feeds in my FB page to appear on my website without any luck until now.

    Now it does work but in debugg mode I still get the following error messages:
    – Notice: Undefined offset: 1 in… ($picture_url = urldecode($picture_url_arr[1]);)
    – Notice: Undefined index: name in… ($name = $obj[‘data’][$x][‘name’];)
    – Notice: Undefined index: description in… ($description = $obj[‘data’][$x][‘description’];)

    Am I doing anything wrong? Any clue?

    T.I.A.,
    hip

  27. Will this keep on working? Or is it possible facebook has an API update and you have to update the code on your own website.

    1. @disqus_5mevFn3QMc, as long as Facebook provides the API, I will keep updating this code based on that API. Usually, FB updates their API every few years only.

    1. Hello @amosmos, no, you don’t have to be a manager of your FB page, it can display any FB page timeline feed as long as you have your own access token!

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top