Pipes, JSON, and code for your website

Posted on 03. Mar, 2010 by Kirk in Arts

Although there’s still quite a bit going on with Yahoo Pipes, interest in the gee-whiz user interface seems to be waning around the blogosphere. While the drag-and-drop interface is cool, I think one of the more useful and interesting features of Yahoo Pipes is its ability to export data as JSON data.

Yahoo makes all of its data — including Pipes feeds data — available as JSON. JSON — Javascript Object Notation — is just data presented as Javascript code. That means you can write Javascript to work directly on the data without any XMLHttpRequest objects to open, get and parse. And because Yahoo provides a nifty callback mechanism, you don’t run into the cross domain security issues that plague Ajax developers — everything runs on the client and Yahoo Pipes enables some truly interesting mashup possibilities that go way beyond the “aggregate 200 feeds and filter on my keywords and pull in some Flickr photos” examples that dominate most blog discussion on Yahoo Pipes.

Code for your site

The most frequently asked question I see on the Pipes discussion boards seems to be “How to I put Pipes feeds on my website?” Here are code examples showing how you can pull data from a Pipes JSON feed and display it automatically on any web page.

  1. Get the JSON feed data. Here’s the code to do that. Replace “PipeID” with the feed you’re interested in. Be sure to retain “_render=json&_callback=pipeCallback”. More about the callback parameter later. Make sure this script is someplace it will be executed when the HTML page loads.
     <script type="text/javascript"  src="http://pipes.yahoo.com/pipes/pipe.run?_id=pipeID&_render=json&_callback=pipeCallback"> </script>

    If you need a real life example, try this:

     <script type="text/javascript" src="http://pipes.yahoo.com/pipes/pipe.run?_id=lLJMf7HH2xGlUlFRJjBjOg&_render=json&_callback=pipeCallback"> </script>

  2. Write some CSS. To keep my example simple, I’ll use <div> to put things where I want to go. Because this is a callback function, you can’t just use document.write because you don’t know where the text will actually end up unless you use CSS to place the text. You can define this however you want, but in my sample code I’ll use a CSS ID called “leftside” and define a left sidebar.
    #leftside { position:absolute; left:10px; width:180px; border:1px solid black; font-size:0.8em; padding:8px; margin:8px;}

  3. Create the callback function.The <HEAD> section of the HTML page is as good a place as any to put this code.
    <script type="text/javascript">function pipeCallback(obj)  document.write("<div id=leftside><h3>My Pipes Feed</h3>"); var x; for (x = 0; x < obj.count ; x++) {
    
     var buildstring = "<b><a href=" + obj.value.items[x].link + ">" + obj.value.items[x].title + "</a></b>. <span id=desc>" + obj.value.items[x].description + "</span><br />"; document.write(buildstring); buildstring = null; } document.write("</div&gt");
    
    }</script>

  4. Some explanation. The function pipeCallback is called by the JSON method that you loaded in Step (1) above. Note that the name of the function matches the _callback parameter you used in calling the first script. obj is the JSON object with one or more members. I’ll describe the members in the next step. You can modify this function to change how the link text looks and where the text is placed, but in this example the Title will be a link to the URL of the original article, and the description is also displayed. In real life, you may want to limit the number of items that are actually displayed.
  5. Arrays and fields. obj.count is the number of members that are in the object. obj.value.items is an array of the members. These members may have different elements depending on how the Pipe was constructed — you’ll need to look at the actual JSON data to see what’s specifically available — but typical RSS feed things will be there, including
    • obj.value.items[x].title — the title of the article.
    • obj.value.items[x].description — the text or summary of the article.
    • obj.value.items[x].link — the URL to the original article.
    • obj.value.items[x].pubDate — the publication date of the article.

If you’re able to make use of this code, please feel free to post your example in the comments.

6,432 Responses to “Pipes, JSON, and code for your website”

  1. car insurance quotes

    30. Jul, 2010

  2. Guyguygsduyguygd

    30. Jul, 2010

    buy cialis 20mg – buy cialis online in usa buy valium online no prescription – buy valium online without prescription buy phentermine online no prescription – buy phentermine online no prescription buy xanax online legally – generic xanax buy ambien canada – buy ambien avis sur kamagra up – kamagra order buy phentermine diet pills – phentermine buy cialis 5mg – buy cialis tramadol – buy tramadol cheap buy viagra online cheap – buy viagra online without prescription

  3. who obama scholarship

    30. Jul, 2010

    comment6 criteria early care and education grants

  4. Sad

    30. Jul, 2010

    Nice and pretty!, used diesel car, =-((, visonik car audio, 272, auto car loan max, =-((, enterprise rent a car resume, 2274, tony stewart race car, 617, Texas car insurance laws, hkq, matchbox 1964 brm raceing car, :-[[, toyota car models, 8-DD, bankruptcy car loan used, lwxp,

  5. Guyguygsduyguygd

    30. Jul, 2010

    buy cialis – buy generic cialis buy valium online without prescription – buy valium online no prescription buy phentermine – buy phentermine 37.5 generic xanax – buy xanax buy ambien online no prescription – buy ambien online without prescription kamagra gel – kamagra 100 chewable tablet buy phentermine – buy phentermine 37.5 buy cialis 20mg – buy cialis buy tramadol 50mg – buy tramadol online without a prescription buy viagra canada – buy viagra cheap

  6. comment3 az grants for women business

  7. Somika Lopa

    30. Jul, 2010

  8. jonn2

    30. Jul, 2010

  9. Guyguygsduyguygd

    30. Jul, 2010

    buy cialis generic – buy cialis valium – buy valium online no prescription buy phentermine – phentermine buy xanax online without prescription – buy xanax overnight delivery buy ambien without a prescription – buy ambien without a prescription kamagra oral jelly premature ejaculation – kamagra soft buy phentermine – buy phentermine 37.5 buy generic cialis – buy cialis online buy tramadol – buy tramadol overnight buy viagra online without prescription – buy viagra online no prescription

  10. grant for college books

    30. Jul, 2010

    comment2 pennsylvania grants for women businesses

  11. jonn1

    30. Jul, 2010

  12. jonn1

    30. Jul, 2010

  13. Guyguygsduyguygd

    30. Jul, 2010

    cialis – buy cialis professional buy valium – valium buy phentermine online – phentermine xanax – xanax buy ambien – buy ambien flibanserin girosa kamagra viagra – kamagra leukopenie buy phentermine – phentermine buy cialis – buy cialis professional tramadol – buy tramadol online buy viagra – buy viagra in mexico

  14. Roma

    30. Jul, 2010

    Wow, very good!, John michael richardson jewelry, wyua, Home information insurance, =-(((, Buy dragon tales party supplies, 058844, Campbells food, 0199, Illegal pelvic exam, 051983, Ada menu, 8879, Golf equiptment for sale, 06512, Crown apartments emerald, 634, Kingdom hearts hentai gay, >:))), The card security card service, 168,

  15. Katja

    30. Jul, 2010

    As for me, I think so too!, Enrique iglesias songs download, 457841, Cheap full color postcard printing, 3663, Aborigine food, qftc, Transaxle for lawnmower, >:-[[, Movies gold poen, >:(, Good command in english, =[[[, Pearl river ny brewery, 8)), Genesis silver barbecue cover, >:-DDD, Jessica hicks jewelry, mcfu, Harem sex slaves, =-PP, Gold medal paperback originals, 8-OOO, Fhm games, xagdya, Hunterdon health and wellness center, vcfbfl,

  16. lasix online

    30. Jul, 2010

    comment3 order doxycycline online by fedex

  17. jonn1

    30. Jul, 2010

  18. Guyguygsduyguygd

    30. Jul, 2010

    buy cialis online – buy cialis online valium – buy valium overnight buy phentermine no prescription – buy phentermine generic xanax – buy xanax online buy ambien online without prescription – buy ambien without a prescription buy cheap cheap kamagra uk viagra – buy kamagra online paypal payment buy phentermine no prescription – buy phentermine buy cialis from canada – buy generic cialis buy tramadol online overnight – buy tramadol buy viagra without prescription – viagra

  19. jonn3

    30. Jul, 2010

  20. comment3 clomid online no prescription

  21. Guyguygsduyguygd

    30. Jul, 2010

    buy cialis generic – buy cialis without prescription buy valium no prescription – buy valium without prescription buy phentermine no prescription – buy phentermine xanax – buy xanax overnight delivery buy ambien – buy ambien online without prescription viagra valium kamagra discreet uk europe – kamagra oral jelly premature ejaculation buy phentermine no prescription – buy phentermine online buy cialis – buy cialis without prescription buy tramadol – buy tramadol no prescription buy viagra online without prescription – buy viagra online cheap

  22. jonn1

    30. Jul, 2010

  23. auto insurance general

    30. Jul, 2010

  24. Guyguygsduyguygd

    30. Jul, 2010

    buy cialis canada – buy cialis 20mg buy valium overnight – buy valium online buy phentermine diet pills – phentermine cheap xanax – buy xanax buy ambien online no prescription – buy ambien girosa kamagra viagra – forum opinie kamagra w aelu buy phentermine diet pills – buy phentermine buy cialis online – buy cialis online in usa buy tramadol online without a prescription – buy tramadol online without a prescription buy viagra online canada – buy viagra online canada

  25. comment3 order doxycycline

  26. jonn2

    30. Jul, 2010

  27. jonn1

    30. Jul, 2010

  28. comment5 order adipex p no prescription

  29. jonn2

    30. Jul, 2010

  30. Guyguygsduyguygd

    30. Jul, 2010

    buy cialis – buy cialis 20mg valium – buy valium online no prescription buy phentermine without prescription – buy phentermine online no prescription buy xanax overnight delivery – buy xanax overnight delivery buy ambien – buy ambien without a prescription buy cheap cheap kamagra uk viagra – kamagra order buy phentermine online – buy phentermine buy cialis generic – cialis buy tramadol – buy tramadol cheap buy viagra online canada – buy viagra in mexico

  31. jonn2

    30. Jul, 2010

    comment3, sony walkman video converter, :-D DD, sync software for samsung sgh a437, ong, sony 2gb mp3 player, 062889, sony dcr trv 320 battery chargers, wjcfax, peter greenburg travel guy, ajmkn, sony cd player tuneup, 87958, life insurance galveston, %-OO, engines from japan, hjov, deb blair poker, 8-PPP, maytag engines, 8722, samsung yp t9 j8 not recognized usb, :-( (, auto reserve, raqxip, cox auto trader inc, ohrer, strip poker fuckin sexy xxx video nude p, 907783, sterling investors life insurance compan, :], travel medical insurance vancouver bc, cne,

  32. jonn2

    30. Jul, 2010

Leave a Reply