6 min read


What Are Feeds?

Feeds are the way to publish news in Facebook. As we have already mentioned before, there are two types of feeds in Facebook, News feed and Mini feed. News feed instantly tracks activities of a user’s online friends, ranging from changes in relationship status to added photos to wall comments. Mini feed appears on individuals’ profiles and highlights recent social activity. You can see your news feed right after you log in, and point your browser to http://www.facebook.com/home.php. It looks like the following, which is, in fact, my news feed.

Feeds in Facebook Applications

Mini feeds are seen in your profile page, displaying your recent activities and look like the following one:

Feeds in Facebook Applications

Only the last 10 entries are being displayed in the mini feed section of the profile page. But you can always see the complete list of mini feeds by going to http://www.facebook.com/minifeed.php. Also the mini feed of any user can be accessed from http://www.facebook.com/minifeed.php?id=userid.

There is another close relation between news feed and mini feed. When applications publish a mini feed in your profile, it will also appear in your friend’s news feed page.

How to publish Feeds

Facebook provides three APIs to publish mini feeds and news feeds. But these are restricted to call not more than 10 times for a particular user in a 48 hour cycle. This means you can publish a maximum of 10 feeds in a specific user’s profile within 48 hours. The following three APIs help to publish feeds:

  • feed_publishStoryToUser—this function publishes the story to the news feed of any user (limited to call once every 12 hours).
  • feed_publishActionOfUser—this one publishes the story to a user’s mini feed, and to his or her friend’s news feed (limited to call 10 times in a rolling 48 hour slot).
  • feed_publishTemplatizedAction—this one also publishes mini feeds and news feeds, but in an easier way (limited to call 10 times in a rolling 48 hour slot).

You can test this API also from http://developers.facebook.com/tools.php?api, and by choosing Feed Preview Console, which will give you the following interface:

Feeds in Facebook Applications

And once you execute the sample, like the previous one, it will preview the sample of your feed.

Sample application to play with Feeds

Let’s publish some news to our profile, and test how the functions actually work. In this section, we will develop a small application (RateBuddies) by which we will be able to send messages to our friends, and then publish our activities as a mini feed. The purpose of this application is to display friends list and rate them in different categories (Awesome, All Square, Loser, etc.).

Here is the code of our application:


include_once("prepend.php"); //the Lib and key container

if (!empty($_POST['friend_sel']))
$friend = $_POST['friend_sel'];
$rating = $_POST['rate'];
$title = " just Rated
as a '{$rating}' ";
$body = "Why not you also rate your friends?";

//now publish the story to user's mini feed and on his friend's news feed
$facebook->api_client->feed_publishActionOfUser($title, $body,
null, $null,null, null, null, null, null, null, 1);
} catch(Exception $e) {
//echo "Error when publishing feeds: "; echo $e->getMessage();

Welcome to RateBuddies, your gateway to rate your friends

Seect a friend:

idname="friend_sel" />

And your friend is:

value="funny" />Funny
value="hot tempered" />Hot Tempered
value="awesome" />Awesome
value="naughty professor" />Naughty Professor
value="looser" />Looser
value="empty veseel" />Empty Vessel
value="foxy" />Foxy
value="childish" />Childish


index. php includes another file called prepend. php. In that file, we initialized the facebook api client using the API key and Secret key of the current application. It is a good practice to keep them in separate file because we need to use them throughout our application, in as many pages as we have. Here is the code of that file:


// this defines some of your basic setup
include 'client/facebook.php'; // the facebook API library
// Get these from ?http://www.facebook.com/developers/apps.php
http://www.facebook.com/developers/apps.php$api_key = 'your api
key';//the api ket of this application
$secret = 'your secret key'; //the secret key

$facebook = new Facebook($api_key, $secret);
//catch the exception that gets thrown if the cookie has an invalid
session_key in it
try {
if (!$facebook->api_client->users_isAppAdded()) {
} catch (Exception $ex) {
//this will clear cookies for your application and redirect them
to a login prompt
$facebook->set_user(null, null);

The client is a standard Facebook REST API client, which is available directly from Facebook.

If you are not sure about these API keys, then point your browser to http://www.facebook.com/developers/apps.php and collect the API key and secret key from there. Here is a screenshot of that page:

Feeds in Facebook Applications

Just collect your API key and Secret Key from this page, when you develop your own application.

Now, when you point your browser to http://apps.facebooks.com/ratebuddies and successfully add that application, it will look like this:

Feeds in Facebook Applications

To see how this app works, type a friend in the box, Select a friend, and click on any rating such as Funny or Foxy. Then click on the Rate Buddy button. As soon as the page submits, open your profile page and you will see that it has published a mini feed in your profile.

Feeds in Facebook Applications

Subscribe to the weekly Packt Hub newsletter

* indicates required


Please enter your comment!
Please enter your name here