Facebook Wall Feed for WordPress

Image of Facebook Status on Personal Blog

Here is an example of what I was able to come up with to get my wall updates from Facebook on my WordPress blog site.

*UPDATE – JUNE 23, 2011: I finished the blog post for the new version of my Facebook Wall Feed for WordPress code. Please refer to the new code from now on as the code and information here doesn’t work anymore.*

*UPDATE – June 21, 2011: At the beginning of June Facebook changed the way they handle calls to get the wall updates. The code given on this page will no longer work. I have made some updates to my code to get it to work for my site and am working on the write up for instructions on how to get it working the new way*

With all the Facebook plug-ins that were available for WordPress, I assumed that they would have one that would display your feed from your Facebook wall. I was wrong. So I set out to find a solution.

In my searches on Google I found many answers on how to do this for the previous version of Facebook. In the previous version there was a way you could find the RSS link of your wall feed and use that to display it on WordPress or any external website. It appears that the new version of Facebook no longer has this ability. When I tried it, the link would always just redirect me to my profile page. This is not what I was looking for. I wanted to be able to display my status updates on my blog so those that are either not on Facebook or those that aren’t my friends on Facebook could still keep up with my updates.

So I had to break out my programming skills and come up with my own solution. It actually was a little easier than I had first anticipated. The biggest problem was that the feed returned JSON objects. Unfortunately I have not really had much experience with JSON. So this was a learning opportunity for me. Once I was able to parse the JSON objects I could then have the output written as HTML. Now all that was left was to organize it and format it to have the same look as other Facebook elements. This wasn’t that hard, but it is very time-consuming.

So for starters I just concentrating on the status updates. I will have to find time for the Places updates, link posts, photo posts, etc…I figure if I can get around to it I would love to get that done and then make it a WordPress plugin to help others out. I have already started on a php class to handle everything. If there is anyone that is familiar with making a WordPress plugin and would like to help, please contact me. I’m all for sharing the work load.

Facebook comments:

Fedil

I was originally born in Missouri, but traveled around most of my childhood. My mom finally got tired of moving while we were in Dallas, Texas and I have been here ever since. After high school I started college at the University of North Texas (UNT) and started working in the computer field. I currently work for JCPenney as a front end software engineer for their e-commerce website. Before this I worked for AT&T about 12 years and started with them in 1999 (when they were Southwestern Bell). I have many passions and I really love photography. Besides photography I also love sports. I not only like to watch it, but I also love to play. Currently my friends and I play indoor soccer and flag football.

47 Comments:

  1. i’ve been searching for a couple of days for this. would you post how you were able to do it? even getting just the status updates would be great. thanks.

  2. Would you be able to provide a little more detailed instructions for us noobs?

    • I’ll try LOL The problem is since I haven’t made it into a plugin you have to do a lot of stuff manual. Sorry.

      Hopefully you have either ftp or ssh access to the server that is hosting yourwebsite. If you do you will need to upload the class file I provided above to the directory of your theme and rename it uki_facebook_wall_feed.php. Once you do that you would then need to add the example lines of code from above and put it where you want it to be displayed. In my case I put it in the sidebar.php file. I hope this helps a little.

      If someone knows of a quick easy way for me to make this a plug-in or would make it a plug-in I would be greatly appreciated.

  3. Hi mate;

    I can’t seem to make it work…The layout appears but not feed is displayed. Look:

    http://140caracter.es/27/2/feed.php

    Thanks in advance.

    • Did you verify that your Facebook privacy settings were completely open? Also do you have all three of the following lines with the ###### replaced with your Facebook ID? If you don’t mind, what is your Facebook ID? That way I can check to see if I can pull it.

      $feed = new uki_facebook_wall_feed(‘#########’);
      $feed->get_fb_wall_feed();
      $feed->display_fb_wall_feed();

      • I set everything to Everyone, and I’m still getting this problem. :(

        • What is your facebook id? I’ll see if it works on my test page.

        • Not sure if you got my email or not, but when to access your facebook page directly it wouldn’t let me see anything. It only showed the section for your basic info and didn’t show your wall at all. It also gave a message that had the privacy lock on it that read: “Kyle only shares some profile information with everyone. If you know Kyle, add him as a friend.”

          So either it didn’t save your privacy changes or you didn’t open up the correct settings.

      • Hi! Thanks for the reply!

        I don’t want the script to display my feed, I want it to display my page’s feed, here is the id of the page: 187909351222336

        Thanks again!

        • I haven’t really looked at how the page feed works vs the status feed. I started this with just the intent to grab my status updates so I could include it here in my blog too. If I get some spare time I might be able to look into adding more options, but as of right now I just want to accomplish the status update feed.

  4. To those that are having problems with nothing showing up. Could you add the following line to in the uki_facebook_wall_feed.php file in the function display_fb_wall_feed():
    echo “

    Count = ” . count($fbFeed) . “

    “;

    So the first few lines of the function should look like this:

    function display_fb_wall_feed()
    {
    $fbFeed = $this->fbWallFeed["data"];
    echo “<p>Count = ” . count($fbFeed) . “</p>”;

  5. So I see your status on the right.

    When I put the code in, it posted what others had posted on my wall and not my statuses. *help!*

    • Thanks! I just wanted to make sure my code was actually working. If it’s not showing anything there are only 2 reasons I can think of. 1st is that your privacy settings aren’t completely open to allow everyone to see your wall updates. 2nd is that you might need to create a facebook app. I have done this for some other things, but maybe it is needed for this and I just didn’t notice since I already had it setup. You should be able to follow the following directions and just put in your blog url instead of example one listed:
      http://ottopress.com/2010/how-to-setup-your-facebook-connect-application/

  6. Yeah i’ve done it for other things too. I’ll try later and update.

    Do you know if there’s a way to edit the code to only show my status updates. I thought yours was doing that but then I scrolled and saw it was showing other feeds too. I had set everything to public when I was testing.

    • Cool. Yea let me know if you get it to work.

      Actually it is set to only display status updates. Unfortunately if someone writes on your wall it is considered a status update. That is why you see those. It doesn’t show my links, videos, or places check-ins. So basically status updates count as anything written on your wall. Maybe there is a privacy setting that you can limit who can see other people’s posts on your wall?

  7. Hey,
    Thanks for the code…I have spent hours trying to find some way to do this (impossible with how often they change Facebook!). I am having some trouble with implementing the code. Basically, I did all of the changes you mention but it comes up with the white box and then “Count = 0″. Any suggestions? The site I am trying to get this into is a test site at http://www.oliviermg.com/mwm/.

    If we can get this working, I might be able to help packaging it into a Plug-In. If I can, I would be more than happy to.

    Thanks!

    • Hey Michael,
      I went to your site and I see a few posts. Did you get it working? Or did you find something else? The only guess I can come up with for the people who are getting the blank white box and 0 count is that either the permissions aren’t completely open or you have to register your website as a facebook app (http://ottopress.com/2010/how-to-setup-your-facebook-connect-application/). That link should give a general idea how to do it if you don’t know how. Let me know if you have done that step. I’m curious if that fixes this particular problem.

  8. Hi Fedil,

    First thanks for taking this task on. Been looking for a solution to this for a while.

    When I paste on of your lines of code into a browser:

    https://graph.facebook.com/ID/feed?limit=100

    and put the correct [ID] in place I get a page displaying the feed. However, the same id produces comments, etc. from people who have liked articles, but have NOT commented on the wall for that ID. The behavior is a bit bizzarre. Wonder if you have seen this.
    Let me know if you have any questions.
    Thanks,
    Bert

    • Bert,
      Thanks! I’m not sure I have seen that. I know if you put that url into a browser it spits back everything from your profile wall. So it includes comments, likes, links, photos, and status updates. The code I wrote only looks for the ones marked as status updates since that is the only one I got around to parsing in my php code. I eventually want to be able to parse everything and even include the comment and like counts.

  9. Hi Fedil,

    thanks for your time to do this..

    it was returning no results for me too and all I had to do was to change the feed url to not-secure http:

    https://graph.facebook.com/$id/feed?limit=100

    to

    http://graph.facebook.com/$id/feed?limit=100

    • Nikos,
      Thanks for the feedback. It is nice to know you got it working. I had not even thought of that. I wonder why mine works with the https. I guess it doesn’t matter though. Hopefully others that are having issues will see this and try it. Hopefully it works for them as well.

  10. Working great for me – time to tweak some of that CSS to make it really tasty. Thanks for code – this was an epic Facebook fail in my opinion.

  11. It appears that attempting to use this alternative with HootSuite has some issues – especially when shrinking a URL and posting a status update.

    Otherwise, it’s working great for me.

    I was able to remove the Facebook profile pic (some of my followers have questionable pics and since this is a business site, best to keep that bit out) and create a string of posts.

    Thanks again!

    • You’re welcome! I’m glad it works. Yea feel free to hack the crap out of the code to get it to work for your needs. I’m hoping to add to this and get it to display links, places, etc when I get some extra time.

  12. Thanks Fedil an excellent solution.

    I copied your code and it worked first time.

    The format is however not very like facebook’s (e.g. photo’s are not floated left of the rest of the comments, etc..

    Yet the format of your own ‘Facebook Status’ (top right of your page) is very like facebooks.

    Are you happy to provide the css you are using?

    EIther way – thanks

  13. Correction – css link wasn’t working!!
    It is now … and formatting is just like Facebook

    I also want to display the Facebook ‘events’ – do you know how to do this? – thanks

    • Glad you got it working! :) Actually I just moved and am still settling in. Once I get that done I want to do a few more things with this. So I’ll keep you updated.

  14. Ok…just checked out the code again today and it now appears you have to create an access token in order to get this information. So I’ll post an update to the code once I figure that part out and add it in. If anyone else already knows how to do this, please share the info.

  15. Hi Fedil,
    Re getting an access token – I found these 2 pages useful:
    1) How to get an App ID:
    http://www.pakt.com/pakt/?id=ce00f49ed79e17aa&t=How_to_add_Facebook_Connect_to_your_website_using_Javascript
    2) How to get an access_token:
    https://developers.facebook.com/docs/authentication/

    • Thanks. Yea I have seen those. I do already have an app id. Where I’m getting stuck at is the access token. I did go to that page earlier this weekend and used the code for the app access token since I want anyone to see it whether they are on facebook or not. To my surprise it doesn’t show all my posts. It only shows my posts I do via twitter. The ones I post from the site or my Iphone facebook app aren’t showing up. When I use the server method they show it does allow me to see everything, but in order for me to get the access token via that method it requires redirects. As this is only a sidebar item it sucks to have to redirect every page and also won’t allow those that don’t have facebook to see anything. So either facebook has a bug or there is a way around only see certain status updates. Still looking into it.

  16. Ok, I finally figured out the issue. Along with adding the requirement of an access token they also made it to where the app has to ask for specific permissions. After I added everything it now works like it is suppose to. I’ll try to get the updated code on the site for people to download by this weekend. I’ll probably create a new post about this new change.

  17. That is a whole lot of code. For something a bit lighter and secrets to the mystery of the access token:

    http://tahoedesigner.com/2011/06/08/facebook-staus-feed-pia/

    • Thanks for the link, but it is step 2 of it that was giving me trouble. Because the documentation doesn’t specify what authentication you need to ask for in order to see all the posts in the feed. So without that step it still doesn’t work right.

  18. Hi Fedil,

    I use your code to my site and it is work fine untile some day ago. Now, my wall feed not visible to my site but i look your wall feed in this site still visible. What’s wrong with your code?

    • Hey,
      Facebook changed their calls to the status updates and now require an authentication token. I’ve updated my code, but haven’t had time to do a write up on it. I’ll do that later today or tonight and post the new code. I’ll reply back here once I have the write up done and link back to it.

      Thanks,
      Fedil

    • I started the new post last night but wasn’t able to finish it. I should have it done and the new code avail tonight.

  19. Hi Fedil,
    Just wondering if you have the updated code ready yet? I have been trying to get this working on my site but not having much luck.
    Regards,
    Ryan

    • Sorry for the long delays. Things have been very busy for me so I haven’t had as much time as I had hoped. I’m in the process of finishing the write up cause there are more details involved now that Facebook changed the way they do things. I do have the code working though as you can see my status updates on the right. So I know the new code works. I’ll do my best to get it up by tonight. The write up has pretty much a step by step to get it working.

      Fedil

  20. I know this is extremely late, but figure it is better than never right? Well I finally finished the write up for the new version of the code. Please go here: http://fedil.ukneeq.com/2011/06/23/facebook-wall-feed-for-wordpress-updated/

  21. Hi,

    I’m using your wordpress plugin and It works.
    Now I need to transform facebook post I see in my wordpress page in RSS2 feed..

    I need a feed url that shows my facebook wall’s posts..

    Is it possible?

    Thanks

    • I’m sure it is possible. I haven’t really looked into it though. I’m sure you can take the feed that you are getting from the plug-in and then just write something to convert it to the RSS format.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>