
<?php

/**
Get an access token from https://developers.facebook.com/tools/explorer

Long lived Access Token:
1. On the top right, select the FB App you created from the "Application" drop down list
2. Click "Get Access Token"
3. Make sure you add the manage_pages permission
4. Convert this short-lived access token into a long-lived one by making this Graph API call: https://graph.facebook.com/oauth/access_token?client_id=<your FB App ID >&client_secret=<your FB App secret>&grant_type=fb_exchange_token&fb_exchange_token=<your short-lived access token>
5. Grab the new long-lived access token returned back
Grab the access_token for the page you'll be pulling info from



**/



header('Content-Type: text/html; charset=utf-8');


$limit = 10; // The number of posts fetched
$access_token = 'YourAccessToken';
$group_id = 'YourGroupID';
$url1 = 'https://graph.facebook.com/'.$group_id.'?access_token='.$access_token;
$des = json_decode(file_get_contents($url1)) ;
 
 
/**echo '<pre>';
print_r($des);
echo '</pre>';**/
 
$url2 = "https://graph.facebook.com/{$group_id}/feed?access_token={$access_token}";
$data = json_decode(file_get_contents($url2));
?>
<style type="text/css">
.wrapperfb {
 width:100%;
 font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
 float:left;
 }
 
 .topfb {
 margin:5px;
 border-bottom:2px solid #e1e1e1;
 float: left;
 width:90%;
 }
 
 .singlefb {
 margin:3px;
 width:90%;
 border-bottom:1px dashed #e1e1e1;
 float:left;
 }
 
 .imgfb {
 float:left;
 width:60px;
 text-align:center;
 margin:5px 5px 5px 0px;
 border-right:1px dashed #e1e1e1;
 }
 
 .textfb {
 width:75%;
 float:left;
 font-size:12px;
 }
 
 .afb {
 text-decoration: none;
 color: #3b5998;
 }
</style>
 
<div class="wrapperfb">
  <div class="topfb">
 <a class="afb" href='http://www.facebook.com/home.php?sk=group_<?=$group_id?>&ap=1'>
<?=$des->name?></a>
 <div style="width:100%; margin: 1px">
 <?= nl2br( $des->description ) ?>
 </div>
 </div>
 <?
 $counter = 0;
  
 foreach($data->data as $d) {
 if($counter==$limit)
 break;
 ?>
<div class="singlefb">
 <div class="imgfb">
 <a class="afb" 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 class="textfb">
 <span style="font-weight:bold"><a class="afb" 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/>

<?= nl2br( $d->message ) ?><br>

 <?=$d->name?><br>
 <a href="<?=$d->link?>"><img src="<?=$d->picture?>" title="<?=$d->description?>" width="50%" float="center"></a>
 </div>
 </div>
 <?
 $counter++;
 }
 ?>
</div>
