I am trying to get feed from a page using Graph API, but that feed also contains 'story' like "Page liked a photo" along with status and that story don't have any message.
Because of that empty message, loop runs 3 times (as defined) but if one 'story' comes it returns only 2.
To the point: Is there any 'type' or something to filter that story to fall into the feeds? I want feed free from story generated by users action, specifically 'Liked post' thing.
This is my code:
<?php
ob_start();
require_once('fb-sdk/src/facebook.php');
$config = array();
$config['appId'] = '111111111';
$config['secret'] = '111111111111111111111111';
$config['fileUpload'] = false; // optional
$facebook = new Facebook($config);
$pageid = "11111111111111";
$pagefeed = $facebook->api("/" . $pageid . "/posts");
$page_profile = $facebook->api("/" . $pageid . "?fields=name");
$pagename = $page_profile['name'];
echo "<div class=\"fb-feed\">";
$i = 0;
foreach ($pagefeed['data'] as $post) {
if ($post['type'] == 'status' || $post['type'] == 'link' || $post['type'] == 'photo') {
if (!empty($post['message'])) {
echo "<div class=\"fb-update\">";
echo "<div class=\"fb-pic-name\"><img src=\"https://graph.facebook.com/" . $pageid . "/picture\">" . "<span>" . $pagename . "</span></div><p>";
if (strlen($post['message']) > 70) {
echo preg_replace('/\s+?(\S+)?$/', '', substr($post['message'], 0, 70)) . "…";
} else {
echo $post['message'];
}
echo "<a href=\"https://www.facebook.com/" . $post['id'] . "\" target=\"_blank\"> See More</a></p>";
echo "<span class=\"date\">" . date("F, jS, g:i a", (strtotime($post['created_time']))) . "</span>" . "<a class=\"comment\" href=\"https://www.facebook.com/" . $post['id'] . "\" target=\"_blank\">Comment</a>";
echo "</div>";
}
$i++;
if ($i == 3) {
break;
}
}
}
echo "</div>";
ob_flush();
?>
Any help is appreciated.