Skip to content
February 4, 2011 / ranacse05

Show Facebook Group Wall on web site


I was working last night and my task was to show the facebook groups wall on a normal website . It can be done easily using facebook graph api after working an hour it was done. So lets discuses the steps here.

And the output will be something like this

Facebook Group wall

First get the group name,description and photo.

$group_id = '2204685680';
$url1 = 'https://graph.facebook.com/'.$group_id;
$des = json_decode(file_get_contents($url1));

This will return all the basic info and those will be in Json format, after decoding that we’ll get some data

stdClass Object

(
    [id] => 2204685680
    [version] => 0
    [owner] => stdClass Object
        (
            [name] => Fatih Beyaz
            [id] => 709103042
        )

    [name] => PHP
    [description] => PHP: Hypertext Preprocessor

For anyone who uses PHP.
    [privacy] => OPEN
    [icon] => http://b.static.ak.fbcdn.net/rsrc.php/y_/r/CbwcMZjMUbR.png
    [updated_time] => 2006-07-09T11:39:30+0000
)

Now we have to pull the posts. For this we need to add feed at the end of the previous url , and the code will be like 

$url2 = "https://graph.facebook.com/{$group_id}/feed";
$data = json_decode(file_get_contents($url2));

This will return last 25 wall post , we can get more if we want by using &limit=NUMBER .

For the design lets write some css .

<style type="text/css">
 .wrapper {
 width:300px;
 border:1px solid #ccc;
 font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
 float:left;
 }

 .top {
 margin:5px;
 border-bottom:2px solid #e1e1e1;
 float: left;
 width:290px;
 }

 .single {
 margin:5px;
 border-bottom:1px dashed #e1e1e1;
 float:left;
 }

 .img {
 float:left;
 width:60px;
 text-align:center;
 margin:5px 5px 5px 0px;
 border-right:1px dashed #e1e1e1;
 }

 .text {
 width:220px;
 float:left;
 font-size:10px;
 }

 a {
 text-decoration: none;
 color: #3b5998;
 }
</style>

and including all the things together the full code will be like

<?php
header ('Content-type: text/html; charset=utf-8'); 
$limit = 5;

$group_id = '2204685680';
$url1 = 'https://graph.facebook.com/'.$group_id;
$des = json_decode(file_get_contents($url1));


echo '<pre>';
print_r($des);
echo '</pre>';


$url2 = "https://graph.facebook.com/{$group_id}/feed";
$data = json_decode(file_get_contents($url2));
?>
<style type="text/css">
 .wrapper {
 width:300px;
 border:1px solid #ccc;
 font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
 float:left;
 }

 .top {
 margin:5px;
 border-bottom:2px solid #e1e1e1;
 float: left;
 width:290px;
 }

 .single {
 margin:5px;
 border-bottom:1px dashed #e1e1e1;
 float:left;
 }

 .img {
 float:left;
 width:60px;
 text-align:center;
 margin:5px 5px 5px 0px;
 border-right:1px dashed #e1e1e1;
 }

 .text {
 width:220px;
 float:left;
 font-size:10px;
 }

 a {
 text-decoration: none;
 color: #3b5998;
 }
</style>


<div>
 <div>
 <a href='http://www.facebook.com/home.php?sk=group_<?=$group_id?>&ap=1'>
<?=$des->name?></a>
 <div style="width:100%; margin: 5px">
 <?=$des->description?>
 </div>
 </div>
 <?
 $counter = 0;
 
 foreach($data->data as $d) {
 if($counter==$limit)
 break;
 ?>
 <div>
 <div>
 <a href="http://facebook.com/profile.php?id=<?=$d->from->id?>">
    <img border="0" alt="<?=$d->from->name?>" src="https://graph.facebook.com/<?=$d->from->id?>/picture"/>
 </a>
 </div>
 <div>
 <span style="font-weight:bold"><a href="http://facebook.com/profile.php?id=<?=$d->from->id?>">
<?=$d->from->name?></a></span><br/>
 <span style="color: #999999;">on <?=date('F j, Y H:i',strtotime($d->created_time))?></span>
 <br/>
 <?=$d->message?>
 </div>
 </div>
 <?
 $counter++;
 }
 ?>
</div>

Enjoy 🙂

Advertisements

69 Comments

Leave a Comment
  1. joy06 / Feb 5 2011 4:33 am

    Nice Post after a long time 😀 We want more post from you 😛

  2. tania / Mar 23 2011 5:47 am

    This is a nice article..
    Its very easy to understand ..
    And this article is using to learn something about it..

    c#, dot.net, php tutorial

    Thanks a lot..!

  3. Pieter / May 4 2011 3:21 pm

    Hi, it looks very easy indeed. However, I get what you see under here. Did I forget something?
    It’s the first time I write php …

    Thx for any help

    Pieter

    stdClass Object

    (
    [id] => 2204685680
    [version] => 0
    [owner] => stdClass Object
    (
    [name] => Fatih Beyaz
    [id] => 709103042
    )

    [name] => PHP
    [description] => PHP: Hypertext Preprocessor

    For anyone who uses PHP.
    [privacy] => OPEN
    [icon] => http://b.static.ak.fbcdn.net/rsrc.php/y_/r/CbwcMZjMUbR.png
    [updated_time] => 2006-07-09T11:39:30+0000
    )

    name?>
    description?>
    data as $d) { if($counter==$limit) break; ?>
    from->name?>
    from->name?>
    on created_time))?>
    message?>

  4. totokamer / May 10 2011 2:31 pm

    Very nice and useful.
    But if you post a video You don’t see?

  5. Brick / May 11 2011 10:32 pm

    Could this be possible to make into a module for Joomla 1.6?
    Do I need som library on my server? Graph API?
    Where should that be placed on the server?
    and last should it be referred to in the code somewhere?

  6. Brick / May 12 2011 2:27 am

    Nevermind. I figured it out. Thanks a lot for the code! I made a Joomla 1.6 Module out of this and posted it on main content area by {loadposition xx}
    I see now that this is a WordPress-related board, but it worked anyway.
    Very strange that I can’t find an extension that will do this. I have no experience with programming or php, so it took a while to understand how to implement the css. 🙂

    Issues:
    1. Events posted on wall didn’t show.
    2. Time format of message is in GMT. -> Don’t know how to change to local time. (+02:00 in summer and +01:00 in winter).
    3. In an event
    properties[0]->text)?>
    the time is given in plain text and in english. Not very usefull for showing when the event will be.

  7. Brick / May 12 2011 4:39 pm

    I got the “$d->created_time” working with time offset, but I’m having problem with “$d->properties[0]->text”

    The event time is +7hours wrong from what was entered on Facebook, and the format is different for different events.

    Event 1: May 18, 2011 at 12:00am
    Event 2: Saturday at 6:00pm

    Should be:
    Event 1: May 17, 2011 at 17:00
    Event 2: Saturday at 11:00

  8. Brick / May 12 2011 4:47 pm

    @Pieter:
    Instead of “/home.php?sk=group_&ap=1

    put

    /group.php?gid=

  9. Brick / May 12 2011 4:50 pm

    This didn’t work.

    Check your group’s address link in facebook, and you will see that you will need to change the first a href link.

  10. Todd Lyda / Jun 7 2011 1:01 am

    Does this not work any more?

    I had used this on a site and it worked beautifully until last week or so.

    Any ideas?

  11. Todd Lyda / Jun 7 2011 2:43 am

    Here is the site where it was working: http://handsandfeetproject.org/michelle-meece/

    We using this for profiles and groups. It just mysteriously stopped working.

  12. Todd Lyda / Jun 7 2011 8:47 pm

    This was a facebook change requiring access tokens. I created an app, generated an access token and added it to the end of $url2 = “https://graph.facebook.com/{$my_fb_uid}/feed and it worked!

    • sheniff / Jun 28 2011 6:50 pm

      Please! I can’t find the way to do what you did in your website. Could you please explain me a little how to use the access_token to retrieve the feeds??

      Thank you very much beforehand!!

      • ranacse05 / Jun 28 2011 9:14 pm

        For access token try this http://developers.facebook.com/docs/authentication/ or you can use the test access token from the graph api examples that is
        2227470867|2.AQCFrSKCmx5TAxcl.3600.1309280400.0-761687689|wSZKUEOObQHik82NHUtzPwSKf4w

      • Todd Lyda / Jun 28 2011 9:20 pm

        <?php
        header ('Content-type: text/html; charset=utf-8');
        $limit = 6;

        $url1 = 'https://graph.facebook.com/&#039;.$my_fb_uid;
        $des = json_decode(file_get_contents($url1));

        echo '

        ';
        print_r($des);
        echo '

        ‘;

        $url2 = “https://graph.facebook.com/{$my_fb_uid}/feed?access_token=222601031087438|fEa02JzC7jP_JuopFqXTtBdz1rM”;
        $data = json_decode(file_get_contents($url2));
        ?>

    • Clogg / Dec 6 2011 6:09 pm

      😦 Hi. I know its a bummer, but could you send me like an example of how to do what youve done on that handsfeetproject? something like ” paste this in head, this in body, replace ### parts with what you find there and there and place it along with .php file that looks like this .. on your web”?
      Please.

  13. sheniff / Jun 28 2011 10:12 pm

    ok! thank you a lot!!

    As far as I could see, it seems the access token must be generated by some application of yours and then it will never change, isn’t it?

  14. Todd Lyda / Jun 28 2011 10:20 pm

    Correct. The application doesn’t really do anything, but it does provide me with my AP ID and AP Secret for the access token. Maybe I need to do more with the FB ap to get it to work.

    Your code above + my access token works great until someone posts a picture the group, then the whole feed disappears.

  15. Facebook Group Feed / Aug 30 2011 4:24 am

    See also http://groupfeed.climatesceptics.org/ for the straight rss feed.

  16. assaf / Oct 25 2011 2:54 am

    Hi,
    Great work.
    Somehow it shows only the group header and description without the items…

    • ranacse05 / Oct 25 2011 2:59 am

      You need to pass the access token .

      • assaf / Oct 25 2011 3:01 am

        I did…I register a nwe app, went through all Oaut process, and finally got the key. than I’ve put it here:
        $url2 = “https://graph.facebook.com/{$group_id}/feed?access_token=XXXXXXX”;

        the header shows, but not the items. even the style not affecting like in the example.

  17. assaf / Oct 25 2011 3:27 am

    Is there any option to wrap it in a wordpress widget? there is a huge demand for such thing.

    • ranacse05 / Oct 25 2011 11:01 am

      yes you can bind that with wp , and this post is a bit old so dont know what did they changed on the process .

      • assaf / Oct 25 2011 1:45 pm

        Thanks !

  18. trafalgar / Nov 9 2011 6:35 am

    Thank you for the headstart! For those finding they lose the feed, don’t forget to pass an access token with offline privileges…

  19. fumcbixby / Nov 23 2011 1:16 am

    I’m really new at this and at a loss. How do I create a Facebook App that reveals the Access Token for my Group? I can get to the App Developer page and click on the “create an app”, but that’s about as far as I know how to go. What kind of app do I need to create? (web app, Facebook app, etc). Then what do I do? Sorry for being such a newbie!

  20. fumcbixby / Nov 23 2011 2:29 am

    okay – I think I got a valid Access Token. I just created a basic “App on Facebook” and found the app’s Access Token. It doesn’t relate to the group at all, but maybe that’s okay. But, I have multiple errors showing up (see below). Perhaps this is because I’m using a free php hosting site? Unfortunately our website is built using a template and there’s no way to add php files to it. So, I’m forced to host the file elsewhere. Does anyone know of a free php hosting server that would let me accomplish this task? Thanks!

    Warning: file_get_contents() [function.file-get-contents]: Unable to access https://graph.facebook.com/230628506276 in /www/zzl.org/f/u/m/fumcbixby/htdocs/group3.php on line 7

    Warning: file_get_contents(https://graph.facebook.com/230628506276) [function.file-get-contents]: failed to open stream: No such file or directory in /www/zzl.org/f/u/m/fumcbixby/htdocs/group3.php on line 7

    Warning: file_get_contents() [function.file-get-contents]: Unable to access https://graph.facebook.com/230628506276/feed?access_token=222601031087438|fEa02Jzc7jP_JuopFqXTtBdz1rM in /www/zzl.org/f/u/m/fumcbixby/htdocs/group3.php on line 14

    Warning: file_get_contents(https://graph.facebook.com/230628506276/feed?access_token=222601031087438|fEa02Jzc7jP_JuopFqXTtBdz1rM) [function.file-get-contents]: failed to open stream: No such file or directory in /www/zzl.org/f/u/m/fumcbixby/htdocs/group3.php on line 14
    .

    Warning: Invalid argument supplied for foreach() in /www/zzl.org/f/u/m/fumcbixby/htdocs/group3.php on line 68

    • ranacse05 / Feb 21 2012 11:22 am

      Sorry for late reply but this is what i got

      {
      “error”: {
      “message”: “Invalid OAuth access token signature.”,
      “type”: “OAuthException”,
      “code”: 190
      }
      }

  21. fumcbixby / Nov 24 2011 10:19 pm

    Okay – got it figured out. Found a free hosting site that worked. However, it is not ideal using that option. SO… I posted the question to a Javascript forum and got a response of how to do this using only Javascript and HTML. This will let anyone integrate their Facebook Group with their Facebook FanPage as well!

    http://www.codingforums.com/showthread.php?p=1162842#post1162842

  22. shital / Nov 25 2011 6:59 pm

    Hi this is a nice code

    but i want something new.
    means if i add some news on my websites, and i want to display this news on my facebook wall.
    so what i do for this.
    please help me for this.
    please give me code on php format.

    kindly reply
    shital

    • ranacse05 / Nov 25 2011 9:22 pm

      Google for the rss feed poster .

  23. Abraar / Jan 12 2012 12:08 pm

    You have bring all the feeds on your website its good. But how i can comment from website? Can you help?

    • ranacse05 / Jan 12 2012 12:16 pm

      you need to use custom coded app for that , last time i checked adding comment using api has a bug so not sure if it works now or not .

  24. Gadget Freak / Jan 15 2012 1:42 am

    Thanks will be working with your code really appreciate the effort 🙂

  25. ugo / Feb 7 2012 5:35 am

    That code works for secret group?

    • ranacse05 / Feb 21 2012 11:20 am

      if and only if you are the member and you can input your app access token at the end of the URL .

  26. Damo / Feb 13 2012 6:28 pm

    Hi, Got this working with groups so thanks very much for that, but how do I get it working with profiles?

    When I exchange the group id for the profile id I get a link to the profile but no feed?

    Any Ideas?

  27. cyclopsthere / Feb 21 2012 10:05 am

    I’ve been racking my brain on how to use this on a wordpress site and no luck.

    Any chance this could be a plugin?:)

    • ranacse05 / Feb 21 2012 11:16 am

      Its a bit tough to be a plugin bcoz now you need the access token to get that data . So if you plan to develop the plugin you have to guide the users to collect the access token and then in put that token , except that it’ll not work .

  28. cyclopsthere / Feb 21 2012 7:59 pm

    So it won’t work even if I get an access token?

    I’m just trying to use it on one site but haven’t been able to get it to work.

  29. Alessio / Jun 28 2012 4:37 pm

    I see this result, can you help me?

    stdClass Object
    (
    [id] => 159749727429667
    [version] => 1
    [owner] => stdClass Object
    (
    [name] => Chicco Contin
    [id] => 100000559967038
    )

    [name] => B44 PARCO APPIANI 2012
    [description] => PARCO APPIANI 2012 ….LA FINE DEL MONDO!!!
    VIA MARGHERA, 44 A PADOVA
    VICINO ALLO STADIO APPIANI ED AL PRATO DELLA VALLE!
    MUSICA, FESTA, APEROL SPRITZ!
    [privacy] => OPEN
    [icon] => http://static.ak.fbcdn.net/rsrc.php/v2/yH/r/6-Zo5i7Axnb.png
    [updated_time] => 2012-06-28T09:31:04+0000
    [email] => 159749727429667@groups.facebook.com
    )

    B44 PARCO APPIANI 2012
    PARCO APPIANI 2012 ….LA FINE DEL MONDO!!! VIA MARGHERA, 44 A PADOVA VICINO ALLO STADIO APPIANI ED AL PRATO DELLA VALLE! MUSICA, FESTA, APEROL SPRITZ!

    Warning: Invalid argument supplied for foreach() in /home/radiospr/public_html/prova.php on line

    thank’s

  30. Alessio / Jun 28 2012 4:57 pm

    Hi, I see this result, can you help me?

    stdClass Object
    (
    [id] => 159749727429667
    [version] => 1
    [owner] => stdClass Object
    (
    [name] => Chicco Contin
    [id] => 100000559967038
    )

    [name] => B44 PARCO APPIANI 2012
    [description] => PARCO APPIANI 2012 ….LA FINE DEL MONDO!!!
    VIA MARGHERA, 44 A PADOVA
    VICINO ALLO STADIO APPIANI ED AL PRATO DELLA VALLE!
    MUSICA, FESTA, APEROL SPRITZ!
    [privacy] => OPEN
    [icon] => http://static.ak.fbcdn.net/rsrc.php/v2/yH/r/6-Zo5i7Axnb.png
    [updated_time] => 2012-06-28T09:31:04+0000
    [email] => 159749727429667@groups.facebook.com
    )

    B44 PARCO APPIANI 2012
    PARCO APPIANI 2012 ….LA FINE DEL MONDO!!! VIA MARGHERA, 44 A PADOVA VICINO ALLO STADIO APPIANI ED AL PRATO DELLA VALLE! MUSICA, FESTA, APEROL SPRITZ!

    Warning: Invalid argument supplied for foreach() in /home/radiospr/public_html/prova.php on line

    thank’s

  31. BrettAdamsGA / Jul 3 2012 7:04 pm

    Thanks for the information, I had to adjust it a bit by adding an access token, and I adjusted the css to fit my needs. Thanks for the basis for the script though. I appreciate it.

  32. ouradu / Jul 6 2012 12:11 am

    Hi! I’ve tried messing around with this code, and can’t get it to work. I get this error each time (this example simply using your exact code).

    Warning: file_get_contents(https://graph.facebook.com/2204685680/feed) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /home/shanecole/thefffl.com/fbtest.php on line 16

    PHP PHP: Hypertext Preprocessor For anyone who uses PHP.

    Warning: Invalid argument supplied for foreach() in /home/********/********.com/fbtest.php on line 71

    Obviously the **** are just personal site info.
    What am I doing wrong?

  33. Johnny / Jul 9 2012 8:47 am

    Has anyone been able to get this to work recentyl? Any updated directions because seems like this is pretty old and no longer works. Would be great if it did because i can’t seem to find anything else online that does this.

  34. Justin Labadie / Jul 18 2012 5:39 am

    This is really sweet coding! I am wondering though Is there a way to display the images and video URLs people post into the ‘feed’?

  35. computertnt / Jan 4 2013 5:38 pm

    how to get group ID

  36. Daniel Hughes / Feb 22 2013 8:50 pm

    Is there anyway to pull this off on WordPress, in a widget, such as using an iframe?

  37. sunil / Apr 1 2013 7:53 pm

    thanks for this information.. but i have a question ? how auto refresh facebookgroup feed on my website..i use auto refresh by ajax but didn’t work plz anyone have solution?

  38. Ibnu Asad Zulfahri / May 26 2013 5:01 pm

    I’ve made some changes to the script to include further explanation on getting the access token and group id. I’ve also fixed the HTML Styling 🙂

    Get it here: http://pastebin.com/LPnzUQSF

    • Mikael Nylén / Apr 19 2014 12:02 am

      Thank you for a easy-to-setup code!
      Is it possible to show pictures embedded in the posts? 🙂

    • Mikael Nylén / Apr 23 2014 12:49 am

      I edited your script a bit, it now display links, images and replace \n (newline) with so that linebreaks in a facebook post is now displayed properly on the website.

      Get it here: http://pastebin.com/91jUHXht

  39. sachin jariyal / Jun 5 2013 7:14 pm

    i want same thing but for other user who are posting in our facebook page .plz help trying for many days you can email me your link to sachin.satsan@gmail.com

  40. Martin / Jan 23 2014 10:37 am

    Hey huys, I need that code!!! here is my group URL

    https://www.facebook.com/groups/educoreflexyon/

    Can someone build the code for that group please!!! And send it by email to martin2049@hotmail.com

    I will copy-past it to my website HTML code.

    I thank you so much

    • Mikael Nylén / Apr 23 2014 12:50 am

      My edited code below
      Get it here: http://pastebin.com/91jUHXht

      • Mario / Oct 23 2016 6:40 pm

        Hi Mikael, thanks for the code.

        1. I assume FB have changed things today, so it won’t work? Getting PHP errors such as “”.

        2. OR..could it be that FB also has to review and approve my app request for access token first, based on me requesting a “manage_pages” permission? I saw a red box above that app will be reviewed.

        3. OR.. I am using a free dynamic DNS service no-ip.com, you think FB is blocking this?

        Any feedback will be appreciated, thank you.

  41. Jasa Pembuatan Website / Aug 27 2014 7:13 pm

    So if my visitors want to post to group he/she will redirect to facebook group first ?

  42. Castro Electronic Arts / Sep 24 2014 5:42 pm

    I would like to thank you for the efforts you’ve put in penning this website.
    I am hoping to see the same high-grade blog posts by you in the future as
    well. In fact, your creative writing abilities has motivated
    me to get my own, personal blog now 😉

  43. create dating website / Oct 17 2014 1:05 pm

    Hey there I am so thrilled I found your web site, I really found you by
    error, while I was browsing on Digg for something else,
    Anyhow I am here now and would just like to say thank you for a fantastic post and a all
    round exciting blog (I also love the theme/design), I don’t
    have time to read through it all at the minute but I have
    book-marked it and also added in your RSS feeds, so when I have time I will
    be back to read a great deal more, Please do keep up the excellent b.

  44. travail domicile / Oct 17 2014 7:54 pm

    Hello everyone, it’s my first pay a quick visit at this web
    page, and paragraph is in fact fruitful designed for
    me, keep up posting these content.

  45. boomirajan / Apr 23 2015 2:55 pm

    I have some questions about limit

  46. boomirajan / Apr 23 2015 2:56 pm

    limit only 0-9 i need nearly 50 limit it’s possible

  47. Tata / Jun 5 2015 1:54 pm

    Very nice. I got it working like this
    http://singer.pk/facebook/rss.php

    using this pastebin
    http://pastebin.com/91jUHXht

    1- It only show the main thresd but not showing replies.
    2- Showing image placeholder eventhere is no image posted
    3- Can it posted as normal atom/rss that can be read by rss reader.

    My aim it to post this Group RSS to Facebook Page using IFTTT with format like this
    https://www.wallflux.com/atom/770012136412755 alas wallflux is not free

    Thanks

  48. Kitanga Nday / Jun 20 2015 10:52 am

    I have a question: What if I wanted to use html instead of php. How would I do this.

  49. Bryan / Jan 3 2016 8:44 am

    Is their any plugin for Facebook group stream in your website?

  50. thehinh2016 / Mar 22 2016 12:31 pm

    i want add this to Blogger. How i can do it 😦

  51. Brent Mags / Jul 7 2016 9:18 am

    is there anyone having a working current version of this for website embed?

    Thanks in advance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: