• Home
  • About Jon Dowdle
  • Lifestream
  • Code from TDD Demystified through Kat...
    Passing

    A big thanks to everyone that came out for today's CFMeetup. The code is located here and the presentation is located here. While practicing for this presentation, I noticed [...]

    Read more
KEEP IN TOUCH

Query the Web with a Simple Tag: YQL Custom Tag + examples

Sep10
2009
Written by Jon Dowdle

I've created a Coldfusion tag to make using YQL (even) easier. I was really surprised to find nothing doing this already. I'm not sure if it is just to simple in the first place or that there is a general lack of interest. Feel free to shed some light on this in the comments. Enough talking already, lets get some demo action going.

The basic usage is pretty similar to another oh-so familiar tag:

<cf_yql>
Select * from flickr.photos.recent
</cf_yql>

<cfloop query="cfyql">
 <!---Format of the static urls to flickr images--->
 <cfoutput>
   <img src="http://farm#farm#.static.flickr.com/#server#/#id#_#secret#_s_d.jpg" />
 </cfoutput>
</cfloop>

Creates...

Top Flickr Photos

As you can see, the format is pretty similar to cfquery. The table name "flickr.photos.recent" is table supported by the YQL (for a full listing of available tables see the footnotes).

Here is another example using an RSS feed:

<cf_yql format="query">
select * from rss where url='http://rss.news.yahoo.com/rss/topstories'
limit 5
</cf_yql>

<cfloop query="cfyql">
 <li>
 <cfoutput><a href="#link#">#title# &mdash; #Source# &mdash; #pubdate#</a>
 <div>#description#</div>
 </cfoutput>
 </li>
</cfloop>
</ul>

Creates...

News Feed

In the future, I'd like to take this further by using YQL's newly added 'execute' functionality.

The project is hosted on github. Feel free to fork me or download the code here.

Edit: Yes, I know this looks like Ray Camden's cf_yql example (http://www.coldfusionjedi.com/index.cfm/2009/9/10/Yahoo-Query-Language) posted earlier today (9/10/09). I had written this post originally on 8/28 and just never got around to publishing it. Ray just lit a fire under my arse by posting his, so thanks Ray!

Items referenced while writing this post:
  • YQL OpenData Tables: http://github.com/spullara/yql-tables/tree/master
  • YQL Execute: http://developer.yahoo.net/blog/archives/2009/04/yql_execute.html
  • http://eatyourgreens.org.uk/archives/2009/04/building-a-kml-feed-with-yql-and-coldfusion.html
Posted in Programming
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« Finding international characters with MySQL
» I’m attending CFinNC

2 Comments

  1. Rudi's Gravatar Rudi
    September 11, 2009 at 7:51 am | Permalink

    Nice work! Thanks for posting this.

    • Jon Dowdle's Gravatar Jon Dowdle
      September 18, 2009 at 7:39 am | Permalink

      @Rudi, thanks man!

Recent Posts

  • Code from TDD Demystified through Katas
  • Awesome Web Development Links Found This Week
  • Taggable Demo Video (now with more code)
  • Taggable Demo Video
  • New jQuery Plugin: Taggable

Categories

  • Code
    • MySQL
    • Programming
    • Web Design
  • coldfusion
  • Life
    • Events
  • Reviews
  • Uncategorized
  • Work

Tags

adobe barcamp barcamporlando coldfusion ComplexByteArrayException concat conferences decorator design pattern Events firebug Form fowa html IE ignite infection control iterator javascript job jQuery movies MySql orlando Photos pirate booty pirates plugins poll project python railo software development sql stackoverflow stax.net style taggable tags talk like a pirate tips & tricks tools twitter washington dc Web Design

RSS Syndication

  • All posts
  • All comments

EvoLve theme by Theme4Press  •  Powered by WordPress jDowdle.com