Yql ans geo
-
Upload
mosesvijay -
Category
Technology
-
view
304 -
download
2
description
Transcript of Yql ans geo
![Page 1: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/1.jpg)
http://www.flickr.com/photos/han_shot_first/6573340265/
![Page 2: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/2.jpg)
YQL1 API to rule them all
http://www.flickr.com/photos/han_shot_first/6573340265/
![Page 3: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/3.jpg)
What• YQL is Yahoo! Query Language
– Web service– SQL like syntax– SELECT * FROM internet;
![Page 4: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/4.jpg)
WhatUnstructured data
Data via YQL
![Page 5: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/5.jpg)
Console
![Page 6: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/6.jpg)
Console
Tables are here
![Page 7: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/7.jpg)
Console
Your query goes here
![Page 8: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/8.jpg)
Console
Output is here
![Page 9: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/9.jpg)
Console
Take-away URL here
![Page 10: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/10.jpg)
Output• XML
– Human & machine readable
• JSON– Javascript object notation– A JS object {}
• Key, value pairs including arrays
– Callback supported• func_name({“json”:”object”})
![Page 11: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/11.jpg)
Output
![Page 12: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/12.jpg)
Unstructured data• Page scrapping
• select content from html where url="http://in.news.yahoo.com/murray-takes-two-set-lead-final-against-djokovic-153758871.html" and xpath='//*[@id="mediaarticlebody"]/div/p[29]’
• Xpath – path to a node in an XML document
![Page 13: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/13.jpg)
Unstructured data• Reading google spreadsheets
• https://docs.google.com/spreadsheet/pub?key=0AgGxPO1AxEhldFZDNzAzQldLSGp2MzVGVXdlUnIxeUE&output=csv
• select * from csv where url = ””
![Page 14: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/14.jpg)
Why• Unstructured data
– Yes, YQL is cool. But …
• Why use YQL– When webservices are already available
• Lets see why, via an example
![Page 15: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/15.jpg)
Example – Profile, Flickr• !YQL
– Get a user profile• http://social.yahooapis.com/v1/user/{guid}/profile
– Search for photos in flickr• http://api.flickr.com/services/rest/?
method=flickr.photos.search&api_key=…&text=djokovic&format=rest
![Page 16: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/16.jpg)
Example – Profile, Flickr• YQL
– Get a user profile• select * from social.profile where guid = me
– Search for photos in flickr• select * from flickr.photos.search where
api_key="..." and text="san francisco"
![Page 17: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/17.jpg)
Examples – Content Analysis
![Page 18: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/18.jpg)
Examples – Content Analysis
![Page 19: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/19.jpg)
Unstructured data, easy api access. What else?
http://www.flickr.com/photos/brickultra/7178444546/
![Page 20: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/20.jpg)
SQL like… JOINS?
• YQL does not support joins natively• Supports sub-selects
– Let’s look at an example
![Page 21: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/21.jpg)
SQL like… JOINS?
1. Get content from a web page
![Page 22: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/22.jpg)
SQL like… JOINS?
2. Identify entities in that content
![Page 23: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/23.jpg)
SQL like… JOINS?
3. Search for photos with entity names
![Page 24: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/24.jpg)
SQL like… JOINS?• A small demo
– http://doc1.ydn.gq1.yahoo.com/mybloglog_test/yqljoin.html
– JOINs doesn’t mean single API call• YQL still makes multiple calls
– Only one IN allowed per select• Sub-select can also have one IN
![Page 25: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/25.jpg)
How? – Devil is in the details
http://www.flickr.com/photos/prodiffusion/8267223638/
![Page 26: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/26.jpg)
How to use• PHP
$yql_query = "select * from answers.getbycategory where category_id=2115500137";$yql_url = "http://query.yahooapis.com/v1/public/yql?q=" . rawurlencode($yql_query) . "&format=json";
$session = curl_init($yql_url); curl_setopt($session, CURLOPT_RETURNTRANSFER,true); $json = curl_exec($session);
![Page 27: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/27.jpg)
How to use• Javascript
![Page 28: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/28.jpg)
Ask. Answer. Discover
Y! Answershttp://www.flickr.com/photos/funkyporcupine/8290971054/
![Page 29: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/29.jpg)
Answers - Tables
![Page 30: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/30.jpg)
http://developer.yahoo.com/answers/
![Page 31: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/31.jpg)
Where, what’s there and how to reach
Geohttp://www.flickr.com/photos/carthalis/3562768042/
![Page 32: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/32.jpg)
Current Location - Ask• Ask the user
![Page 33: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/33.jpg)
Current Location - Ask• Ask the browser
![Page 34: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/34.jpg)
Current Location - Ask
![Page 35: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/35.jpg)
Current Location - Sniffhttp://isithackday.com/hacks/geo/js-location.html
![Page 36: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/36.jpg)
Geocoding
![Page 37: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/37.jpg)
Reverse geocoding
![Page 38: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/38.jpg)
Woeid• Where-On-Earth-ID
![Page 39: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/39.jpg)
WoeidSELECT placeTypeName, name FROM geo.places.ancestors WHERE descendant_woeid = "55925520”
SELECT placeTypeName, name FROM geo.places.ancestors WHERE descendant_woeid = "55925520”
![Page 40: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/40.jpg)
Geoplanet
![Page 41: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/41.jpg)
Placemaker
![Page 42: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/42.jpg)
Geo Hacks• http://trendsmap.com/local/india• http://isithackday.com/hacks/geo/
![Page 43: Yql ans geo](https://reader034.fdocuments.in/reader034/viewer/2022050808/54bd61cb4a79599c0a8b468a/html5/thumbnails/43.jpg)
Happy hacking!
Thank Youhttp://www.flickr.com/photos/brickaholicproductions/5177947158/