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:
[source=’php’]$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
}[/source]
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.
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:
[source=’php’]$feed_template = “{‘filmname’:'”.$film_name.”‘, ‘images’:[{‘src’:'”.$film_cover.”‘, ‘href’:’http://apps.facebook.com/snagfilms’}]}”;echo ‘‘;[/source]
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.