YQL Query: YQL Flickr Requery
In this example, the Flickr Recent Photos YQL table is used to pull in a small set of recent Flickr images every 8 seconds.
Setting Up the Query
The easiest way to build a YQL query is by visiting the YQL Console. In this example we will be using the flickr.photos.recent
table. The YQL
statement that we are using looks like this:
SELECT * FROM flickr.photos.recent
SELECT * FROM flickr.photos.recent
Setting Up the YUI Instance
Now we need to create our YUI instance and tell it to load the yql
and node
modules.
YUI().use('node', 'yql')
YUI().use('node', 'yql')
Making the Query
Now that we have a YUI instance with the yql
module, we can now make a query.
YUI().use('node', 'yql', function(Y) { var res = Y.one('#res'), count = 0, url = '<a href="http://flickr.com/photos/{owner}/{id}"><img src="http://static.flickr.com/{server}/{id}_{secret}_t.jpg"></a>'; var q = Y.YQL('select * from flickr.photos.recent', function(r) { count++; res.setContent('<h2>Recent Flickr Photos <em>(query #' + count + ')</em></h2>'); Y.each(r.query.results.photo, function(v) { res.append(Y.Lang.sub(url, v)); }); }); Y.later(8000, q, q.send, null, true); });
YUI().use('node', 'yql', function(Y) { var res = Y.one('#res'), count = 0, url = '<a href="http://flickr.com/photos/{owner}/{id}"><img src="http://static.flickr.com/{server}/{id}_{secret}_t.jpg"></a>'; var q = Y.YQL('select * from flickr.photos.recent', function(r) { count++; res.setContent('<h2>Recent Flickr Photos <em>(query #' + count + ')</em></h2>'); Y.each(r.query.results.photo, function(v) { res.append(Y.Lang.sub(url, v)); }); }); Y.later(8000, q, q.send, null, true); });