Blog

Display your latest facebook posts in your website

Facebook has no option right now to generate your post as feed structure. So you can not get your post feeds. But still you can get the list of your posts and show them in your website or blog. In my last post (Share the comments of your youtube Video in your website) I mentioned the steps to get the feed from youtube and now I am writing the same with a different way for Facebook.


facebook postsHere is the PHP code. You need to place this in your template.

<?php
//function to retrieve posts from facebook’s server
function loadFB($fbID){
$url="http://graph.facebook.com/".$fbID."/feed?limit=3";
//load and setup CURL
$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
//get data from facebook and decode JSON
$page = json_decode(curl_exec($c));
//close the connection
curl_close($c);
//return the data as an object
return $page->data;
}
//BE SURE to enter your facebook id here
$fbid="190506416472588";
//how many posts to show
$fbLimit=10;
//variable used to count how many we’ve loaded
$fbCount=0;
//call the function and get the posts from facebook
$myPosts=loadFB($fbid);
//set timezone (change this to your timezone)
date_default_timezone_set("America/Chicago");
//loop through all the posts we got from facebook
foreach($myPosts as $dPost){
//only show posts that are posted by the page admin
if($dPost->from->id==$fbid){
//get the post date / time and convert to unix time
$dTime = strtotime($dPost->created_time);
//format the date / time into something human readable
//if you want it formatted differently look up the php date function
$myTime=date("M d Y h:ia",$dTime);
?>
<ul>
<li><?php echo($dPost->message);?>
<?php echo $myTime;?></li>
</ul>
<?php
//increment counter
$fbCount++;
//if we’ve outputted the number set above in fblimit we’re done
if($fbCount >= $fbLimit) break;
}
}
?>

Two things you must do for working out this script.

1. Make sure your server is cURL enabled
2. You will have change the Facebook ID in the script by yours.

That’s all…

  • Roors Philip

    This is a great info you shared. I will try it on my site :)

    Thanks buddy.

  • Mohon Shrinibhasana

    Got some tricks from other blogs but none of those works. They are still showing info about fb rss which no longer exists. Just checked this to my demo and it works fine.

    thanks a lot, waiting for more research work on it. keep posting.

  • http://www.diigo.com/profile/adajramon Kate Mccue

    I am very interested in. May I ask to spoon feed the detail please?

  • http://www.womenshealthdoc.com/index.php/member/8595/ Zola Marable

    Nice work. You keep working on this blog please.

  • http://www.orstudents.org/forums/member/211812/ Truck Pilot

    Awesome work! Keep posting good material.

  • http://hellloadajramon.tumblr.com/ William Johson

    I am very interested in. May I ask to spoon feed the detail please?

  • http://sneakerheads.pt-eliten.no/ Erasmo

    Greetings I stumbled on your blog by mistake when i searched Live search for this topic, I have to point out your blog is actually helpful I also love the style, it is superb!

  • http://www.campaignmonitor.com/forums/profile.php?section=personal&id=154765 How To Quit Smoking

    You must be a genious. I love your posts, will come back later.

  • http://www.fdfdkivklplofdeww-v.co Andre Belman

    Lovely site! I am loving it!! Will come back again. I am bookmarking your feeds also

  • http://www.meteo.it/ Andrea Barczak

    thanks for sharing

  • http://www.wavesdream.com admin

    Thanks a lot all of you for your feedback :)

  • http://nevropathielingedemaison.tanie-pozyczki.waw.pl/ nathalie

    I will talk about it to my friends. Thanks ;)

  • http://www.thoughts.com/ty1324morin/photography-san-diego-shooting-in-panorama Melodee Labrada

    Im grateful for the blog post. Really Cool.

  • http://www.karenmilles.co.uk karen millen dresses

    Thank you for your provided information.

  • http://sharecashbypass.comuf.com Sharecash Bypass

    Would love it if someone would further explain this to me?

  • http://www.9gwebsolutions.com simarjeet singh

    hi

    thanks is script

    working very well,

    but i have a question?

    is there any limit to access data my mean to hit a URL .

    is there any limit to hit a URL on facebook in one day or month.

    hope u can understand what i am asking you.

    thanks

    • http://www.wavesdream.com admin

      There is no limit.

  • http://www.icc-forum.nl/invision/index.php?showuser=86027 Gale Soderberg

    Thank for this great post, i like what you read.

  • http://www.chioutletsale.org/2011/05/oconnell-introduced-incentives-reward-officers-men-armed-forces Denese Schrupp

    Terrific post, plenty of really good data. I wish to show my friend and get them the things they think.

  • Sandra

    It has worked perfectly till now… if you go to url http://graph.facebook.com/190506416472588/feed?li… you get an error "An access token is required to request this resource." anyone knows the problem?

  • http://www.june72011.net Sophie

    Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Anyway I'll be subscribing to your feed and I hope you post again soon.

  • http://www.9gwebsolutions.com simarjeet singh

    hello,

    this script is not wrork now, please help me why this happen , return error is

    {

    "error": {

    "type": "OAuthException",

    "message": "An access token is required to request this resource."

    }

    }

    how i can get a access token.

    thanks

  • http://www.dphajduka.com/smfforum/index.php?topic=7343.new#new Nona Crosser

    decided listing you procure

  • http://www.garagedoor-intercom.com/garage-doors.html Garage Doors NJ

    This really answered my problem, thank you!

  • http://www.herrellplumbing.com Rex Brauer

    Love the information here. Adding to my bookmarks. Thank you!

  • http://www.buybacklinkservices.com Luther Cassel

    I must know where you got your layout from im trying to start my own blog and yours is the coolest.

  • http://ehowtoimprovecreditscore.com Bredgediema

    Thanks For This Blog, was added to my bookmarks.

  • http://dowoli.com.pl/zabiegi-antycellulitowe-krakow Tommy Busk

    It’s some shame you don’t have a relatively donate press button! I’d most certainly donate to this excellent blog! I just think in the meantime i’ll settle for bookmarking not to mention putting a Rss feed towards your Search engine profile. I just take a look ahead towards unique updates and often will promote this unique weblog with the help of your Squidoo group: )

  • http://allcity.pl/folie Johnnie Stpierre

    It’s your pity you actually don’t have got a donate switch! I’d most likely donate to this remarkable blog! I actually suppose that at this point i’ll settle for book-marking plus placing a person's Rss feed so that you can this Bing akun. I actually glance forth so that you can fresh posts but will show the following blog site by using this Twitter group: )

  • http://catalogue.info.pl/manicure-hybrydowy-krakow Nigel Blancarte

    It’s an important pity you actually don’t have a very good donate link! I’d most likely donate to this spectacular web site! As i presume at this point i’ll be happy with book-marking and even placing ones own Rss feed to help you a Google and yahoo credit account. As i start looking forwards to help you innovative posts and will eventually publish it website through a Facebook . com group: )

  • http://the-free-sample-color-contact-lenses.blogspot.com Nicholas William

    Your website is fantastic, great ideas and very professional. TQ

  • http://ezinearticles.com/?A-Glimpse-At-Herbal-Slimming-Products&id=4962671 Aura Casini

    This is very interesting, You are a very skilled blogger. I've joined your feed and look forward to seeking more of your excellent post. Also, I have shared your site in my social networks!

  • http://www.marketingbacklinks.com Terri Coverstone

    Wow! Your article has quite a few comment posts. How did you get so many readers to look at your post I'm envious! I'm still learning all about article writing on the web. I'm going to click on more articles on your website to get a better idea how to attract more people. Thank you!

  • http://www.osbmxauctions.com Ethelene Montas

    I just found this Site. Just wanted to let you know that I really like it.

  • http://www.thoughts.com/bionical45/the-top-music-programs-for-the-motorola-bionic Claudine Lagle

    Fantastic goods from you, man. I have understand your stuff previous to and you are just extremely wonderful. I really like what you've acquired here, really like what you are stating and the way in which you say it. You make it enjoyable and you still care for to keep it wise. I can not wait to read far more from you. This is actually a tremendous website.

  • http://www.journalhome.com/dustinfisherwvd/176338/donkey-kong-country-the-ultimate-game.html Carroll B. Merriman

    Hi there would you mind letting me know which hosting company you're utilizing? I've loaded your blog in 3 completely different browsers and I must say this blog loads a lot quicker then most. Can you suggest a good internet hosting provider at a fair price? Thanks, I appreciate it!

  • http://e-reader-comparison.org/ Vicky Basler

    Hey there, You've done a great job. I’ll definitely digg it and personally suggest to my friends. I am confident they will be benefited from this site.

  • http://horvatia.org/forum/index.php?action=profile;u=25534 Johanna Malory

    Excellent articles, There’s a lot of nice info here, although Used to do want tell you something, I’m operating Redhat together with the up-to-date beta associated with Firefox, and also the look of your site is kind of wonky for me personally, I'll check out content articles, but the routing doesn’t function so well.

  • http://hojny.com Brinda Dech

    This is tough. I?m not pointing fingers at you though, personally I think that its those that aren?t motivated to

  • http://www.scamsites.info/story.php?id=813137 Ahmad Cabreja

    Applause for this post – one of your best!

  • http://www.imba-it.de Melani Tramontano

    I’m not that big of a web reader to be honest, your site is really nice, keep it up! I’ll go on and save your website to come back in the future. Greetz from solar

  • http://mobileskills3.angelfire.com/mobile-blog-4.html Willow Gollnick

    Boys Love Loose Moms

  • http://community.atom.com/Post/seo-tips/03EFBFFFF02428A1B00080157A029?ref_title=roberter21q4&amp Florine Wloch

    Thought I would comment and say neat theme, did you code it on your own? It looks really good!

  • http://www.article-smart.com/Art/355420/79/A-Cleveland-SEO-Company-Will-Get-Your-Website-Ranking-aro Stanley Clarbour

    Great content material and great layout. Your blog deserves all of the positive feedback it's been getting.

  • http://www.countrylanegazebos.com/pavilions.asp pavilions

    Good article , thanks and we want more! Added to FeedBurner as well

  • http://www.fivestararticles.com/Article/The-Basic-steps-of-Binary-Option-Trading/287716 Deangelo Schuchmann

    Right here is the kind of information I've long been searching for. Thank you for writing this information.

  • http://knxmnow5.webs.com/apps/blog/entries/show/8176615-cost-to-start-a-restau Nelida Dye

    as I website possessor I conceive the subject matter here is very excellent , thankyou for your efforts.

  • http://www.bodyinmotiondc.com denver chiropractors

    Thanks for the great info.

  • http://www.linkdir.eu Velda Aitkin

    I delight in, lead to I found exactly what I was looking for. You have ended my four day lengthy hunt! God Bless you man. Have a great day. Bye

  • http://gertgambell.net/play-on-odds/worldbet-have-closed-down-another-bookmaker-is-gone/ Anette Dezell

    I am glad that I discovered this web blog, exactly the right information that I was searching for!

  • http://www.formacionalternativa.com Ronn

    Well, I read all your posts for now…I'llcome back tomorow for more great posts!

  • http://www.freearticledirectoryonline.com/Art/228215/24/A-Brief-History-of-Call-Recording.html Rashad Heemstra

    You have some seriously important information composed here. Excellent job and keep posting great stuff.

  • http://google.com Jordon Papitto

    Hi there could I use some of the information from this site if I link back to you?

  • http://frederickpctech.com Donn Daubendiek

    sweet blog thanks for to make it

  • iliyas

    hi, thanx for the code. I’ve tried it but it shows me error..

    [error] => stdClass Object
    (
    [message] => An access token is required to request this resource.
    [type] => OAuthException
    [code][/code] => 104
    )

    can you help me out?