Up Arrow

Get all feeds from Facebook fan page using Graph API

  • Date: June 3rd, 2014 | by Masum
  • Facebook
  • Tweet
  • Googleplus
  • IN

Using the Graph API you are able to post new stories, upload photos, retrieve posts and a variety of other tasks that an app might need to do. This guide will teach you how to accomplish all feeds from your Facebook fan page using Graph API with the PHP SDK.

Step 1:
Download latest Facebook PHP SDK from Facebook Developer Docs (Link: )
Step 2:
Create an APP from your Developer account (Link: )
Step 3:
Unzip Facebook SDK. Move it into your website’s folder. For example –
My website’s folder name is FacebookFeed and I moved Facebook SDK into FacebookFeed with renamed Facebook SDK as FacebookPhpSdk.
Step 4:
Now take a PHP file, configure Facebook SDK as below –


require_once('FacebookPhpSdk/src/facebook.php');
$config = array();
$config['appId'] = 'APP ID';
$config['secret'] = 'App Secret ID';
$config['fileUpload'] = false; // optional
$facebook = new Facebook($config);
$pageid = "Fan Page ID";
$pagefeed = $facebook->api("/" . $pageid . "/feed");
foreach($pagefeed['data'] as $post)
{
   print_r($post);
}

Recent Posts