Yql ans geo

43
http://www.flickr.com/photos/han_shot_fir 6573340265/

description

 

Transcript of Yql ans geo

Page 1: Yql ans geo

http://www.flickr.com/photos/han_shot_first/6573340265/

Page 2: Yql ans geo

YQL1 API to rule them all

http://www.flickr.com/photos/han_shot_first/6573340265/

Page 3: Yql ans geo

What• YQL is Yahoo! Query Language

– Web service– SQL like syntax– SELECT * FROM internet;

Page 4: Yql ans geo

WhatUnstructured data

Data via YQL

Page 5: Yql ans geo

Console

Page 6: Yql ans geo

Console

Tables are here

Page 7: Yql ans geo

Console

Your query goes here

Page 8: Yql ans geo

Console

Output is here

Page 9: Yql ans geo

Console

Take-away URL here

Page 10: Yql ans geo

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

Output

Page 12: Yql ans geo

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

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

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

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

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

Examples – Content Analysis

Page 18: Yql ans geo

Examples – Content Analysis

Page 19: Yql ans geo

Unstructured data, easy api access. What else?

http://www.flickr.com/photos/brickultra/7178444546/

Page 20: Yql ans geo

SQL like… JOINS?

• YQL does not support joins natively• Supports sub-selects

– Let’s look at an example

Page 21: Yql ans geo

SQL like… JOINS?

1. Get content from a web page

Page 22: Yql ans geo

SQL like… JOINS?

2. Identify entities in that content

Page 23: Yql ans geo

SQL like… JOINS?

3. Search for photos with entity names

Page 24: Yql ans geo

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

How? – Devil is in the details

http://www.flickr.com/photos/prodiffusion/8267223638/

Page 26: Yql ans geo

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

How to use• Javascript

Page 28: Yql ans geo

Ask. Answer. Discover

Y! Answershttp://www.flickr.com/photos/funkyporcupine/8290971054/

Page 29: Yql ans geo

Answers - Tables

Page 30: Yql ans geo

http://developer.yahoo.com/answers/

Page 31: Yql ans geo

Where, what’s there and how to reach

Geohttp://www.flickr.com/photos/carthalis/3562768042/

Page 32: Yql ans geo

Current Location - Ask• Ask the user

Page 33: Yql ans geo

Current Location - Ask• Ask the browser

Page 34: Yql ans geo

Current Location - Ask

Page 35: Yql ans geo

Current Location - Sniffhttp://isithackday.com/hacks/geo/js-location.html

Page 36: Yql ans geo

Geocoding

Page 37: Yql ans geo

Reverse geocoding

Page 38: Yql ans geo

Woeid• Where-On-Earth-ID

Page 39: Yql ans geo

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

Geoplanet

Page 41: Yql ans geo

Placemaker

Page 42: Yql ans geo

Geo Hacks• http://trendsmap.com/local/india• http://isithackday.com/hacks/geo/

Page 43: Yql ans geo

Happy hacking!

Thank Youhttp://www.flickr.com/photos/brickaholicproductions/5177947158/