15. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
…
16. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
…
…
if (flickcurl_prepare(fc,
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
17. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
…
…
if (flickcurl_prepare(fc,
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
http://search.yahooapis.com/
ImageSearchService/V1/imageSearch?
appid=YahooDemo&query=Corvette&results=2
18. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
…
…
if (flickcurl_prepare(fc,
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
http://search.yahooapis.com/
ImageSearchService/V1/imageSearch?
appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/
forecastrss?p=FRXX0076&u=c
19. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
…
…
if (flickcurl_prepare(fc,
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
http://search.yahooapis.com/
ImageSearchService/V1/imageSearch?
appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/
forecastrss?p=FRXX0076&u=c
20. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
…
…
if (flickcurl_prepare(fc,
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
http://search.yahooapis.com/
ImageSearchService/V1/imageSearch?
appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/
forecastrss?p=FRXX0076&u=c
21. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
…
…
if (flickcurl_prepare(fc,
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
http://search.yahooapis.com/
ImageSearchService/V1/imageSearch?
appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/
forecastrss?p=FRXX0076&u=c
22. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
…
…
if (flickcurl_prepare(fc,
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
http://search.yahooapis.com/
ImageSearchService/V1/imageSearch?
appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/
forecastrss?p=FRXX0076&u=c
23. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
?
…
…
if (flickcurl_prepare(fc,
?
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
? http://search.yahooapis.com/
ImageSearchService/V1/imageSearch?
appid=YahooDemo&query=Corvette&results=2
?
http://weather.yahooapis.com/
forecastrss?p=FRXX0076&u=c
24. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
?
…
…
if (flickcurl_prepare(fc,
?
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
? http://search.yahooapis.com/
ImageSearchService/V1/imageSearch?
appid=YahooDemo&query=Corvette&results=2
?
http://weather.yahooapis.com/
forecastrss?p=FRXX0076&u=c
25. var map = new
YMap(document.getElementById('map'));
…
dev var currentGeoPoint = new
YGeoPoint( _c.Lat, _c.Lon );
map.addMarker(currentGeoPoint);
…
…
if (flickcurl_prepare(fc,
"flickr.photos.geo.correctLocation",
parameters, count)) { … }
…
http://search.yahooapis.com/
ImageSearchService/V1/imageSearch?
appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/
forecastrss?p=FRXX0076&u=c
30. Exercise 1
• write a query to search the web for “free
wifi” Washington DC
• find photos of kittens on flickr that were
tagged with “awesome”
• find the weather at SFO (san francisco
airport)
31. Solutions 1
• select * from search.web where query =
'"washington dc" free wifi'
• select * from flickr.photos.search where
text ="kittens" and tags="awesome"
• select * from weather.forecast where
location in (select postal from geo.places
where text="sfo")
32. Demo time part deux
http://developer.yahoo.com/yql/console/
33. Exercise 2
• Get my (“sh1mmer”) twitter stream
• Find articles about Obama in the New York
Times
• Google, Bing and Yahoo for dogs
34. Solutions 2
• select * from twitter.user.timeline where id =
"sh1mmer"
• select * from nyt.article.search where query =
"obama"
• select * from query.multi where queries =
'select * from microsoft.bing.web where
query="dogs";select * from google.search
where q = "dogs"; select * from search.web
where query="dogs"'
35. YQL in Practice
20 tiny steps to a working application
You’ll need:
Firefox
Firebug
Text editor
36. Step 1.
Login to the console with your Yahoo! login
http://developer.yahoo.com/yql/console
37. Step 2.
Find the statement box and
run the first query with test.
57. <script src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js"></
script>
<script>
YUI({
//Last Gallery Build of this module
gallery: 'gallery-2010.01.27-20'
}).use('gallery-yql', function(Y) {
//Using events
var q1 = new Y.yql('select * from github.user.info where (id =
"davglass")');
q1.on('query', function(r) {
//Do something here.
});
q1.on('error', function(r) {
//Do something here.
});
//Or the callback approacha
new Y.yql('select * from github.user.info where (id = "davglass")',
function(r) {
//Do something here.
r.query; //The result
r.error; //The error message
});
});
</script>
58. Advanced
YQL
Advanced Queries, I/U/D, Open Tables and Using YQL
with JavaScript
59. Basics
select * from {table} where {key1} =
"{value1}" and {key2} = {value2}
select * from flickr.photos.search where text
= "kittens" and tags = "domokun"
74. select * from flickr.photos.search(0) where text =
"kittens" and tags = "domokun" and farm = 4 limit 10
75. Limit Summary
• limit 10 - give me max 10 results from the
data you have
• {table}(10) - get ten results from server
• {table}(0) - get enough results from the
server to fill my local limit with the local
filters
84. select * from {table1}
where
({key1}, {key2}) in
(select foo, bar from {table2});
85. select * from flickr.places
where
(lat, lon) in
(select match1, match2 from regex
where
text in
(select entry.point from usgs.earthquakes limit 10)
and expression = "(-?d+.d+) (-?d+.d+)")
and total != 0 limit 10
93. I/U/D
• Personally, I like calling it DUI
• I’m always developing under the influence
94. I/U/D
• Personally, I like calling it DUI
• I’m always developing under the influence
• Insert / Update / Delete tables
95. Just like SQL except...
• INSERT - no where clause. period.
• UPDATE - only remote keys
• DELETE - only remote keys
96. INSERT INTO wordpress.post
(title, description, blogurl,
username, password) VALUES
("Test Title", "This is a test body",
"http://yqltest.wordpress.com",
"yqltestuser", "password");