Ben Ward

Using Yahoo! Pipes to feed Facebook

. Updated: .

Facebook is everyone’s least hated under-one-roof social networking monster. It’s aesthetically neutral, perhaps even pretty. It’s open with feeds and iCal subscriptions and least evil of all, it allows you to specify an external source for your Facebook blog.

This is great step out from other social nets like MySpace, which expect you to remain within their grotesquely decorated walled garden at all times. With Facebook you can pipe content in, without actively using the website itself.

It’s far from perfect, since blogging (‘Notes’) is the only feature which lets you import external content in this way. Unfortunately you can’t set up the Photos application to import from Flickr.

My work-around is to combine my feeds together and import everything into Notes. Come a time that Facebook is more open and flexible, I can always change that.

This is where Yahoo! Pipes comes in, and gets very clever indeed. As well as taking multiple feed sources and merging them, Pipes allows you to manipulate the content of each feed. So I can add a ‘Photo: ’ prefix to the titles of my Flickr photos, and a ‘Ten Word Review: ’ prefix to content from The Ten Word Review. It all helps to make clearer where the mixed content is coming from. Pipes makes it very easy.

First, take a look at the Ben Ward Feed Mungeomatic Pipe. You can clone it to derive your own, or just use it for reference. Yay for sharing.

Pipes presents a clear, visual UI that makes it quite easy to keep track of where the data is moving to, and the order in which alterations are made

You’ll see that there are three separate feed sources. One for each feed (you can put multiple feeds in the same source, but we’re manipulating them differently, so separate sources is the way to go). You’ll also want to make sure that each source is the same format. Mixing Atom with RSS does not a happy pipe make when it comes to sorting.

Now, follow the Flickr feed. The primary way to manipulate the content of feed items is using the Regex operator. This threw me at first. In regular programming, regular expressions are always available, but you expect to find simpler string functions like ‘append’ and ‘sub-string’ as well. Pipes just jumps straight to using Regex for all string manipulation. With that understood, the Regex operator should hopefully be quite clear. The ^ signifies the very start of the string, so replacing with Photos: effectively inserts the text at the beginning. Likewise, replacing $ with text will append to the string.

I only include a subset of photographs, since I don’t want Facebook flooded with every picture I take. Since Flickr doesn’t have RSS feeds for photosets, though, I send the photos I want Facebooked to a personal group and use the RSS feed of that. You could write your own Photoset-to-Feed script using the Flickr API if you wanted, or just use the feed for your entire photostream.

So as well as modify the title, I’m also altering the content of the Flickr feed item (the description). Putting the photos in a group pool means we find strange and redundant ‘Ben Ward added a photo to the pool’ text in the content. That is removed quickly by matching a .* has added a photo to the pool: and replacing it with an empty string.

Similar tricks are performed on the Ten Word Review content, adding a prefix to the title and slightly rewriting some of the content.

The final piece of trickery — more of a bug fix, really — is on the blog feed itself, using the Rename operator. This allows different fields within the feed item to be renamed. So description becomes summary and content:encoded becomes description. This works around an oddity when importing into Facebook where my blog content was being published with HTML mark-up escaped, but not the content from other feeds. Swapping content:encoded to description made it consistent with the other feeds and seems to have resolved the problem.

With the feed content altered, the three sources are combined using a Union operator and then sorted by pubDate. The whole lot is then output as one monster feed.

So far, I’ve found it reliable, although Pipes doesn’t give detailed feedback when it encounters errors, so you’ll need to keep Feed Validator on hand during development if you run into parsing problems with your inputs. On the Facebook side, I seem to have a problem whereby the Flickr entries have been duplicated. That’s happened before when using other feed merging services too, so I think it’s a bug in the Facebook importer.

I hope this is useful, I do recommend having a play with Yahoo! Pipes. It could always be improved with more operators and sources, but right now it does a fine job of mashing content together in neat and tidy ways.

Comments

Previously, I hosted responses and commentary from readers directly on this site, but have decided not to any more. All previous comments and pingbacks are included here, but to post further responses, please refer me to a post on your own blog or other network. See instructions and recommendations of ways to do this.

  1. Nice work! I’ve really started to love facebook – breath of fresh air from other sites such as Myspace… but it can sometimes be restrictive in certain things. I’m looking forward to playing about with all the new apps that keep appearing…
    Tom

  2. Hi, This is great thanks! I had a play with pipes a while ago, but couldn’t come up with anything useful for it, this is ideal, because I can’t be bothered to come up with any additional content for my facebook account!

    Anyway, I seem to have a small problem with my pipe, it was working fine earlier, but since I added my flickr group instead of my basic stream pipes is not picking up my photos. I’m sure it’s something really silly I’ve done – but if you could have a quick look I’d appreciate it: http://pipes.yahoo.com/pipes/pipe.info?_id=QkerxV9P3BG306tbjknRlg

  3. I think the problem must be with pipes or flickr because I’ve just used the “feed auto discover” module & that’s not picking the photos up either.

    Ah, well… try again tomorrow.

  4. Right, I’ve worked out that the issue is with the flickr feed. If you’re not a member of the flickr group you just get an empty feed. Similarly if you visit the group but are not signed in flickr politely tells you to go away.

    How did you get your photos to be publicly visible but prevent others from posting to the group?

You can file issues or provide corrections: View Source on Github. Contributor credits.