Facebook News Feed

Write code to access the Facebook News Feed: I’ve done most of it for you

$facebook_page_id = 'YOUR_PAGE_ID';
$access_token = 'ACCESS_TOKEN';
$no_of_post = 5;
$json_content = file_get_contents("https://graph.facebook.com/".$facebook_page_id."/feed?access_token=".$access_token."&limit=".$no_of_post);

$row_data = json_decode($json_content);
$i=0;
echo "<ul>";
foreach($row_data->data as $feed)
{
$feed_id=explode("_",$feed->id);
if(!empty($feed->message))
{
$i++;
if($i<($no_of_post+1))
{
echo "<li>".$feed->message."</li>";
}
}
}
echo "</ul>";

 

Advertisements
Posted in: PHP

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