Mashing Up Feeds Using Yahoo Pipes

Wednesday, March 26th, 2008 11:06 am by TDH Print this Article Print this page Comments Comment Share This Share This

Yahoo Pipes may just be in beta, but it's already a great tool for web publishers that wants to add a bit of more flair and life to their websites. It's in no way hard to mash up RSS feeds using Yahoo Pipes, and I'll walk you through the most basic way of using the service in this tutorial.

But first of all, why would you want to mash up several RSS feeds into one? Let's do a list of reasons, shall we?!

  • You've got a bunch of sites you like and would like to monitor all in one. Mash them up!
  • You publish a handful of sites and wants your users to subscribe to them all. Mash them up and offer the feed, through Feedburner if you like!
  • You'd like to display relevant stories in your sidebar. Nab the feeds and mash them into one!

That latter one is exactly what we'll be doing here on the next version of Devlounge, and something I'm adding to the new Wisdump design as I'm writing this.

Yahoo Pipes

Let's Mash Those Feeds

It's really easy. Go to http://pipes.yahoo.com, click Create a pipe, and sign in with your Yahoo ID (get one if you don't have one). You get a big grid, a debugger, and stuff to the left for inclusion using drag and drop. Yikes!

Yahoo Pipes - the big grid

So let's get started then. We want to mashup these feeds:

  • Devlounge's RSS feed (http://feeds.feedburner.com/Devlounge)
  • The Blog Herald's RSS feed (http://feeds.feedburner.com/blogherald)
  • Performancing's RSS feed (http://feeds.feedburner.com/performancing)
  • Blogger Jobs' RSS feed (http://feeds.feedburner.com/blogger-jobs)

We could add more, but that'll do for now. I've collected the feeds as you can see.

Now, let's add them. Grab the Fetch Feed badge under Sources in the left menu, and drag it top the big grid. A box gets added, and we also get a second box called Pipe Output. That's where we want the feeds to land.

Elements in Yahoo Pipes

Let's add the feeds. Paste the feed URL in the input field within the Fetch Feed box. Then click the + sign thrice beside the URL to get three more input fields. Add the RSS feed URL:s in these.

All these feeds are powered by Feedburner, as you can tell by looking at their URL:s, and the little icon to the left of them.

Yahoo Pipes - four feeds added

Good.

Now let's sort them so that the most recent one is on top. Click Operators to the left, and drag the Sort field to the grid. For this we want to sort by item.pubDate (when the items in the mashed up feeds where published) so we'll pick that from the first dropdown in the Sort box, and we want it in descending orders so we'll select that in the second one.

Let's make something off this! Click the circle in the bottom of the Fetch Feed box, and drag it to the top circle in the Sort box. Voilá, they're connected! Now do the same from the bottom circle in the Sort box, to the Pipe Output box.

Attaching pipes

There we are. If you want to test it you can click the Refresh link in the debugger below the grid.

Now click Save in the top right, and name your pipe. When it has finished saving, click Run Pipe at the top of the screen. A new window opens, where you can do stuff with your pipe.

Looks good? Then click Publish to make it accessible. Now, what we want is the pipe's RSS feed, so click the More options link to the right and Get as RSS.

There you go, one mashed RSS feed containing the latest from four different feeds!

Adding The Feed To Wisdump

So let's add the feed to Wisdump's sidebar then, shall we? The pipe's feed is this: http://pipes.yahoo.com/pipes/pipe.run?_id=bntjQkH73BGSmXmSjknRlg&_render=rss

So how do we add it? With a RSS parsing plugin? We could, but since Wisdump is powered by WordPress, why not just use WordPress' built-in feed parser? Let's do that.

This little code snippet is well known, several blogs have reported variants of it. It's snatched from the RSS feeds in WordPress' admin.

HTML:
  1. <?php
  2. require_once (ABSPATH . WPINC . '/rss-functions.php');
  3. // insert the feed URL here
  4. $rss = @fetch_rss('http://pipes.yahoo.com/pipes/pipe.run?_id=bntjQkH73BGSmXmSjknRlg&_render=rss');
  5. if ( isset($rss->items) && 0 != count($rss->items) ) {
  6. ?>
  7. <?php
  8. // set the number of items from the feed to display (10)
  9. $rss->items = array_slice($rss->items, 0, 10);
  10. foreach ($rss->items as $item ) {
  11. ?>
  12. <a href='<?php echo wp_filter_kses($item['link']); ?>'>
  13. <?php echo wp_specialchars($item['title']); ?>
  14. </a>
  15. </li>
  16. <?php } ?>
  17. <?php } ?>

This will spit out a list where each item in the pipe's feed is a li list item, so you'll probably want to insert an ul around it.

The key is:

HTML:
  1. // insert the feed URL here
  2. $rss = @fetch_rss('http://pipes.yahoo.com/pipes/pipe.run?_id=bntjQkH73BGSmXmSjknRlg&_render=rss');

...where you insert the feed's URL, and:

HTML:
  1. <?php
  2. // set the number of items from the feed to display (10)
  3. $rss->items = array_slice($rss->items, 0, 10);
  4. foreach ($rss->items as $item ) {
  5. ?>

The number of items you want to display. I went with 10 here.

Here's the code used in Wisdump's sidebar:

HTML:
  1. <ul class="network">
  2.     <h2>News From The Network</h2>
  3.     <?php
  4.     require_once (ABSPATH . WPINC . '/rss-functions.php');
  5.     // insert the feed URL here
  6.     $rss = @fetch_rss('http://pipes.yahoo.com/pipes/pipe.run?_id=bntjQkH73BGSmXmSjknRlg&_render=rss');
  7.     if ( isset($rss->items) && 0 != count($rss->items) ) {
  8.     ?>
  9.     <?php
  10.     // set the number of items from the feed to display (10)
  11.     $rss->items = array_slice($rss->items, 0, 10);
  12.     foreach ($rss->items as $item ) {
  13.     ?>
  14.     <li>
  15.     <a href='<?php echo wp_filter_kses($item['link']); ?>'>
  16.     <?php echo wp_specialchars($item['title']); ?>
  17.     </a>
  18.     </li>
  19.     <?php } ?>
  20.     <?php } ?>
  21. </ul>

You can see it in action over at Wisdump (down a bit in the sidebar), which incidentally has got a new design, so check that out too.

Pipes in action over at Wisdump

Good luck with your feed mashing!

End of Article. Copyright Devlounge.
  • Post Time March 26, 2008 at 11:52 am (permalink)

    Nice Article.
    It seems that you like Yahoo Pipes. I managed to implement almost 30 Yahoo Pipes in my site MacrosReader (http://reader.macrostandard.com/). Just take a look and run a few of it! Thank you.

  • Post Time March 26, 2008 at 1:07 pm (permalink)

    Excellent. Note that Geckotribe’s stuff is capable of this too, and with a lot more flexibility. Carp and Grouper, along with their new Wordpress plugin can give you tons of control.

  • Comment Author TDH
    Post Time March 26, 2008 at 5:11 pm (permalink)

    Thanks.

    There are several services that could do this. I do like Yahoo Pipes though, it’s stable enough. :)

  • Comment Author raj
    Post Time March 27, 2008 at 10:33 am (permalink)

    Thord, I’ve written no fewer than 20 articles on Pipes, including video screencasts, and none of them looked as clear as yours. Good work, especially with that bit of code explanation.

  • Comment Author TDH
    Post Time March 28, 2008 at 4:41 am (permalink)

    Thanks Raj.

    I urge everyone interested in tweaking WordPress to check out Raj’s series on http://performancing.com

  • Post Time March 31, 2008 at 4:19 am (permalink)

    Love this Post. Great tips! Surely will try this

  • Comment Author Ken
    Post Time April 17, 2008 at 11:58 am (permalink)

    Are you all having luck using the Yahoo Pipes RSS feed with fetch_rss? I sure am not :). I get “Warning: Invalid argument supplied for foreach()” about 75% of the time. Which, as you know, looks fantastic when it breaks my site, lol.

    I don’t have any other problems with any other feeds, just Pipes RSS output. I wonder what is special in the RSS that causes that?

  • Pingback : Yahoo! Pipes on March 26, 2008
  • Pingback : Notes from a Teacher: Mark on Media » Monday squibs on April 1, 2008
  • Note: If you are commenting here for the first time, your comment will be sent into a moderation queue before being published. Please use your email address in order to identify yourself for your future comments. Clean XHTML: Use standards ready code tags in your comments. For example, cite a comment or phrase from an article with < blockquote > tags.

    About this author

    LoginI'm a designer, writer, and blogger who's been working professionally online since 1998. Since then I've survived dotcom, published magazines, books, and lots of websites. See more posts by TDH, or visit TDH's homepage.

    Subscribe

    SubscribeFirst time here, or frequent flyer. Whatever the case may be, we highly recommend subscribing to our feeds so you can get the latest updates without visiting the site. It's just a thought - don't say we didn't tell you so.

    Sponsors

    Related Content

    Close
    E-mail It