Saturday, January 5, 2013

How to post facebook app wall feeds onto your own website domain

So here's the problem:  You want to repost a facebook wall status feed onto your own website, what are your options?

You could use pure javascript and this seems to be a popular option.  So why did I not use it?
  1. Using js is not persistent.  if you need to be able to display your entire history of posts, you will need to store them locally which is not possible if using a js only solution
  2. Server side authentication.  I needed to learn more abour rails and the fb api.  It is by fb's own admission the most difficult way to do things, but it has a lot of advantages as will be described in a moment.

What I used to do:

I used to use the hidden rss feeds from facebook to pull the wall feeds using git://github.com/pauldix/feedzirra.git

This was in line with the wonderful railscasts from ryan bates : http://railscasts.com/episodes/168-feed-parsing

So why not continue to use this methodology?  It's simple and it works.  However, the images embedded within the feed are ridiculously small from 90 to 130px in width which make great thumbnails but has little visual impact.

Thew new solution was to leverage the most awesome gem: koala

I was able to make this gem work for a little while late 2012, but evidently the oauth response change the 1.0 version no longer functions and I needed to use the latest version of the gem
gem "koala", "~> 1.6.0rc1"
for fb to respond properly and produce a token.

Besides just an interesting exercise in accessing facebook, why would you go through so much more trouble?

The ability to format and use/skip entries is the holy grail.  If you look at the github repo https://github.com/kimkong/koala-facebook-feed and the feed_helper.rb you will see that there are a lot of different kinds of updates.
The problem is that the facebook docs are not entirely clear on the distinctions between the combinations of entry_type and status_type.  It is possible to have a status_type without a entry_type.

The helper is the product of a purely exploratory endeavor.  I looked at the most common types of posts that my clients were making and made sure that I produced formatted output for those types.  The other types (status posts from others that have no real meaning as a feed) are not displayed at this time.  

There is the possibility of some false negatives; some statuses might be thrown away that shouldn't be.  If you find any such errors, please let me know :)

Oh and another thing, make sure when you setup your developer app on facebook that you have the url set to localhost:3000 when testing and reset it to the domain of your project when ready for the world.

Hope this helps!  I know I spent way more time on this than I envisioned, but sometimes it takes time to develop understanding.