Well, first, I would never use $post as a variable as it could be misread for a $_POST…
(Minor point, but this has caused many programmers issues!)
Well, it appears that you are using the fairly standard FB api interface.
So, I found this on a site that shows how to check for empty data and only display the
live data. It has sections for messages, photo’s and stories. You can see how they did
some minor error checking to skip empty data. And, you can remove the ones you do not
want such as photos… If you still can not sort it out with this sample,
just post back further questions. Good luck, hope this helps…
(Oh, they have a limit of 10 items which is a good idea if someone posts a 100 items.)
[php]
// set counter to 0, because we only want to display 10 posts
$i = 0;
foreach($pagefeed[‘data’] as $post) {
if ($post['type'] == 'status' || $post['type'] == 'link' || $post['type'] == 'photo') {
// open up an fb-update div
echo "<div class=\"fb-update\">";
// post the time
// check if post type is a status
if ($post['type'] == 'status') {
echo "<h2>Status updated on: " . date("jS M, Y", (strtotime($post['created_time']))) . "</h2>";
echo "<p>" . $post['message'] . "</p>";
}
// check if post type is a link
if ($post['type'] == 'link') {
echo "<h2>Link posted on: " . date("jS M, Y", (strtotime($post['created_time']))) . "</h2>";
echo "<p>" . $post['name'] . "</p>";
echo "<p><a href=\"" . $post['link'] . "\" target=\"_blank\">" . $post['link'] . "</a></p>";
}
// check if post type is a photo
if ($post['type'] == 'photo') {
echo "<h2>Photo posted on: " . date("jS M, Y", (strtotime($post['created_time']))) . "</h2>";
if (empty($post['story']) === false) {
echo "<p>" . $post['story'] . "</p>";
} elseif (empty($post['message']) === false) {
echo "<p>" . $post['message'] . "</p>";
}
echo "<p><a href=\"" . $post['link'] . "\" target=\"_blank\">View photo →</a></p>";
}
echo "</div>"; // close fb-update div
$i++; // add 1 to the counter if our condition for $post['type'] is met
}
// break out of the loop if counter has reached 10
if ($i == 10) {
break;
}
} // end the foreach statement
[/php]