Okey-dokey ...
Based on this work :
http://www.acornartwork.com/blog/2010/04/19/tutorial-facebook-rss-feed-parser-in-pure-php/
I came up with this snippet :
<?php
$url = 'http://facebook.com/feeds/page.php?format=atom10&id='.$id;
$maxnumber = $max;
/* The following line is absolutely necessary to read Facebook feeds. Facebook will not
recognize PHP as a browser and therefore won't fetch anything. So we define a browser here */
ini_set('user_agent','Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3');
$feed = simplexml_load_file($url); //Load feed with simplexml
$fb_array = array(); //Initialize empty array to store statuses
foreach ( $feed->entry as $item ) {
if ($maxnumber == 0) {
break;
} else {
$desc = trim($item->title);
if ($desc == '') {
$desc = trim(strip_tags($item->content));
}
//Converts UTF-8 into ISO-8859-1 to solve special symbols issues
$desc = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $desc); //needed?
//Get status update time
$pubdate = strtotime($item->published);
$propertime = gmdate('F jS Y, H:i', $pubdate); //Customize this to your liking
//Get link to update
$linkback = $item->link['href'];
$pos = strpos($linkback, '://www.facebook.com/');
if ($pos === false) {
$linkback = 'http://www.facebook.com' . $linkback;
}
//Store values in array
$fb_item = array(
'desc' => $desc,
'date' => $propertime,
'link' => $linkback
);
array_push($fb_array, $fb_item);
$maxnumber--;
}
}
$output = '';
$output .= '<ul>';
foreach ($fb_array as $k => $v) {
$output .= ' <li>';
$output .= ' <b>' . $v['date'] . '</b>';
$output .= '' . $v['desc'] . '';
$output .= ' <a href="' . $v['link'] . '" target="_blank">Link</a>';
$output .= ' </li>';
}
$output .= '</ul>';
return $output;
?>
(output has some empty quotes as I was messing around with styling and span tags ...)
which gets called in a doc template or sidebar chunk like this
[!fb_feed? &id=`19110642979` &max=`5` !]
(where the id number is the id of the facebook site you’re interested in - in this case that of MODx)
The result is a style-able and click-able list of the most recent postings the facebook owner has posted to their Wall (assuming I understand all this correctly). Note that this would only work for a public site.
FWIW, the wall data - including the most recent comment, comment count etc. - is also available from the facebook api code. But it seemed like overkill and this was was more simple for my needs.
Matt