With the most recent API changes, specifically the one that changed the way fan pages behave so that they look and behave more like Facebook user profiles, Facebook also made a significant change in how newsfeeds work in applications.

Previously, you would send newsfeed items to a user’s profile wall and their main newsfeed using the same API call. Feed.publishUserAction pretty much took care of all of the feed related publishing.

Something like this would do the trick:

$template_bundle_id = 123456789;
$tokens = array();

try {
$facebook->api_client->feed_publishUserAction($template_bundle_id, json_encode($tokens), $array_of_friends_id, '');
} catch(Exception $e) {
// error trapping goes here
}

The code above would insert a one-line story into the user’s profile wall (as seen below), and into their friends’ /home.php newsfeed.

fb_feed

While the profile item is nice, the truly viral aspects come from the friends’ newsfeed items. Most people don’t spend a lot of time on profile pages – they rely on their /home.php page for the overview of what their friends are doing by way of posted items, status updates and application messaging.

With the latest change in the Facebook API, suddenly feeds stopped appearing in the the newly redesigned friends’ newsfeed, now referred to as the “stream”. They were still being pushed to the user’s profile, but as we already mentioned, the usefulness of putting feed items there is somewhat limited.

With these new updates, publishUserAction no longer publishes anything to the users’ friends’ stream, and now only publishes one-line stories to the user’s own profile wall.

Enter Feed Forms and Facebook.showFeedDialog

Using showFeedDialog, the user is prompted whether or not they want to publish the action to their stream. While this does mean changing some application code, switching oer to the new feed system is actually very easy for the most part. (I cannot speak for how one would do it in a Flash-based application, as I haven’t had to tackle that yet.)

Assuming you’ve already created your feed template bundle in the feed template console, you’d do something like this:

$feed_template = "{'filmname':'".$film_name."', 'images':[{'src':'".$film_cover."', 'href':'http://apps.facebook.com/snagfilms'}]}";
	
echo '<script type="text/javascript">
Facebook.showFeedDialog(123456790, '.$feed_template.');
</script>';

As long as you have a short-story version in your feed template, that’s pretty much all you have to do. If your previous feed templates only used one-line stories, you WILL have to create new feed template bundles that use short stories, as one-line stories are NEVER published to the stream. Otherwise, just stick that line of PHP/JavaScript into your form handler (or whatever script completes the action the user is initiating) in your application and you’re back in business.

To further complicate things, Facebook just announced the beta launch of their Open Stream API using Stream.publish, which looks like it might offer a simpler-but-different method by which you can publish feeds. Fortunately for this article – and for the time being, my sanity – the Open Stream API is in beta, and only application developers can publish to their stream from their apps. As more information is available about Stream.publish, I’ll try to keep you updated.

ssd-virtual-servers-banner-468x60

Advertisement

468x60_makemoney
Previous post

%$#^%$* Facebook Application Tabs

Wordify
Next post

Following Me on Twitter

snipe

snipe

I’m a tech geek/dev/infosec-nerd/scuba diver/blacksmith/sword-fighter/crime fighter/ENTP/warcrafter/activist. I'm the CTO at Mass Mosaic and the CEO of Grokability, Inc. in San Diego, CA. Tweet at me @snipeyhead or read more...

  • Sean Carmody

    You rule Alison. Thanks for this post on Facebook Feeds. It clears up quite a bit in a clear and concise way.
    ~Sean Carmody

  • Sean Carmody

    You rule Alison. Thanks for this post on Facebook Feeds. It clears up quite a bit in a clear and concise way.
    ~Sean Carmody

  • Alison, total newbie here, trying to publish short versions of our news articles to our news feed, hoping it will also display on the news feed of our friends. Anyway, your code returns “Facebook is undefined”. I guess I need to link to a javascript, before calling Facebook.showFeedDialog()?
    Thanks for any help you can give!
    Mark

  • Alison, total newbie here, trying to publish short versions of our news articles to our news feed, hoping it will also display on the news feed of our friends. Anyway, your code returns “Facebook is undefined”. I guess I need to link to a javascript, before calling Facebook.showFeedDialog()?
    Thanks for any help you can give!
    Mark

  • Hi Mark – the easiest way to do this would be to create an RSS feed and have the RSS feed automatically import into your Facebook, which is something you can do without any applications at all. You can just go to http://www.facebook.com/editnotes.php?import and set it to pull in your feed. It’s an easier way to handle this, since you don’t need an application to get it done.

  • Hi Mark – the easiest way to do this would be to create an RSS feed and have the RSS feed automatically import into your Facebook, which is something you can do without any applications at all. You can just go to http://www.facebook.com/editnotes.php?import and set it to pull in your feed. It’s an easier way to handle this, since you don’t need an application to get it done.

  • Hi, great post!

    But i have a doubt, in the first example, how do i set a feed template?

    I set my bundle id and call the feed_publishUserAction method like your example but nothing happen. If i use showFeedDialog method works fine.

    PD: Sorry if i wrote something wrong, i don’t speak too much english ^^

    Last blog post: Google Wave…. ¿Qué nos depara el destino?

  • Hi, great post!

    But i have a doubt, in the first example, how do i set a feed template?

    I set my bundle id and call the feed_publishUserAction method like your example but nothing happen. If i use showFeedDialog method works fine.

    PD: Sorry if i wrote something wrong, i don’t speak too much english ^^

    Last blog post: Google Wave…. ¿Qué nos depara el destino?

  • Great tip, thanks so much Alison! Works like a charm!
    Too bad it doesn’t allow the photos of the feed, though.
    Would you happen to have (a link to) an example PHP script of how to publish short stories on FaceBook?
    Thanks!
    Mark

  • Great tip, thanks so much Alison! Works like a charm!
    Too bad it doesn’t allow the photos of the feed, though.
    Would you happen to have (a link to) an example PHP script of how to publish short stories on FaceBook?
    Thanks!
    Mark

  • nice tutorial =D

  • nice tutorial =D

  • Have anyone tried out “google wave” & “FB api” together?

  • Have anyone tried out “google wave” & “FB api” together?

  • adrian

    I am new to the application world of facebook. I created a application, very simple (hello world like) where i have a story with video that I would like users to be able to publish to there news feed. I am tried everything to get this to work, but cannot. I copied your code and put my feed template id in, but nothing shows up. Am i missing something?

    PS: love you site 🙂

  • adrian

    I am new to the application world of facebook. I created a application, very simple (hello world like) where i have a story with video that I would like users to be able to publish to there news feed. I am tried everything to get this to work, but cannot. I copied your code and put my feed template id in, but nothing shows up. Am i missing something?

    PS: love you site 🙂

  • I’ve just started playing around with apps.
    I too was intrigued by the idea that if you create an app and someone interacts with it – then by the mere simple act of them using it – that person could expose all of their friends to your app as well.

    Friends try it – their friends exposed – those friends try it – on and on and on!

    If you’re telling me that option is now completely gone…I think my idea is 100% dead. Are you saying that its now impossible to publish a user’s action to their friends’ streams?

    Is there atleast a way to ASK them if its okay to publish their action to friends’s stream? Sort of like where it asks you if it’s okay to publish your actions to your wall?

  • I’ve just started playing around with apps.
    I too was intrigued by the idea that if you create an app and someone interacts with it – then by the mere simple act of them using it – that person could expose all of their friends to your app as well.

    Friends try it – their friends exposed – those friends try it – on and on and on!

    If you’re telling me that option is now completely gone…I think my idea is 100% dead. Are you saying that its now impossible to publish a user’s action to their friends’ streams?

    Is there atleast a way to ASK them if its okay to publish their action to friends’s stream? Sort of like where it asks you if it’s okay to publish your actions to your wall?

  • That’s not what I’m telling you at all – see the last section, titled “Enter Feed Forms and Facebook.showFeedDialog” – that shows you how to publish to the user’s stream.

  • That’s not what I’m telling you at all – see the last section, titled “Enter Feed Forms and Facebook.showFeedDialog” – that shows you how to publish to the user’s stream.

  • Tri

    Great post,

    That post is make me understand very clearly about one-line, short, full story post on my wall.

    I going to try using Facebook.showFeedDialog, too.

  • Tri

    Great post,

    That post is make me understand very clearly about one-line, short, full story post on my wall.

    I going to try using Facebook.showFeedDialog, too.

  • Harish

    No matter how much i try, I am not able to get the showFeedDialog box to show up. I have a template registered with the tokens – actor,amount already specified. Where am I going wrong?

    My code is like this:

    $img_src = “http://pad.thedigitalmovement.com/_blaise/2007-06-15-dgen-breakfast.jpg”;
    $feed_template = “{‘actor’:'”.$userId.”‘,’amount’:'”.$amount.”‘, ‘images’:[{‘src’:'”.$img_src.”‘, ‘href’:’http://facebook.com’}]}”;
    echo ‘
    Facebook.showFeedDialog(168473468927, ‘.$feed_template.’);
    ‘;

  • Harish

    No matter how much i try, I am not able to get the showFeedDialog box to show up. I have a template registered with the tokens – actor,amount already specified. Where am I going wrong?

    My code is like this:

    $img_src = “http://pad.thedigitalmovement.com/_blaise/2007-06-15-dgen-breakfast.jpg”;
    $feed_template = “{‘actor’:'”.$userId.”‘,’amount’:'”.$amount.”‘, ‘images’:[{‘src’:'”.$img_src.”‘, ‘href’:’http://facebook.com’}]}”;
    echo ‘
    Facebook.showFeedDialog(168473468927, ‘.$feed_template.’);
    ‘;

  • Hi, i was trying to publish a feed story with a image, but i have problems to show the images. In the feed console doesn’t happend. somebody knows what happend with the images in feed story functionality.

    Harish the problem is that u need to put the Facebook.show.. inside a javascript tag.

    thank u
    .-= @lasmovies´s last blog ..Parar la linea de tiempo por x segundos y luego seguir, flash as 2.0 =-.

  • Hi, i was trying to publish a feed story with a image, but i have problems to show the images. In the feed console doesn’t happend. somebody knows what happend with the images in feed story functionality.

    Harish the problem is that u need to put the Facebook.show.. inside a javascript tag.

    thank u
    .-= @lasmovies´s last blog ..Parar la linea de tiempo por x segundos y luego seguir, flash as 2.0 =-.

  • Greg

    Just noticed (10/23/09) that I can choose from Live Feed or News Feed on FB. But they both now show post such as ABS person is now a fan/friend of XYX. I really don't need that on my Wall….I've looked and looked for ways to remove those posts, but to no avail. Thank you.

  • Hi Greg – I'm not really sure that you can just yet. They just rolled out the changes to the newsfeed yesterday. I'll look into it and see if I can find an answer for you, but they may not have set that ability up yet.

  • Just a heads up, guys:

    http://developers.facebook.com/news.php?blog=1&

    So they are going to discontinue support for the way we typically send newsfeeds to the stream:

    This means that we will discontinue support for the following:

    -Template bundles. You should start using stream attachments with the stream publishing methods instead.
    – feed.publishUserAction
    – feed.publishTemplatizedAction
    – Facebook.showFeedDialog and FB.Connect.showFeedDialog
    – Publisher stories that use templates (please transition them to use stream attachments).
    – Feed forms that reference the feedStory form and the multiFeedStory form.
    – One-line stream stories.

    Basically, most of the newsfeed triggers we normally use include templates and Facebook.showFeedDialog, which will evidently stop working on Dec 20.

    I will likely post an article about it within a week or so to further clarify.

  • Hi Greg – I'm not really sure that you can just yet. They just rolled out the changes to the newsfeed yesterday. I'll look into it and see if I can find an answer for you, but they may not have set that ability up yet.

  • Just a heads up, guys:

    http://developers.facebook.com/news.php?blog=1&

    So they are going to discontinue support for the way we typically send newsfeeds to the stream:

    This means that we will discontinue support for the following:

    -Template bundles. You should start using stream attachments with the stream publishing methods instead.
    – feed.publishUserAction
    – feed.publishTemplatizedAction
    – Facebook.showFeedDialog and FB.Connect.showFeedDialog
    – Publisher stories that use templates (please transition them to use stream attachments).
    – Feed forms that reference the feedStory form and the multiFeedStory form.
    – One-line stream stories.

    Basically, most of the newsfeed triggers we normally use include templates and Facebook.showFeedDialog, which will evidently stop working on Dec 20.

    I will likely post an article about it within a week or so to further clarify.