Last active
October 14, 2019 11:32
-
-
Save ydn/68bcc1338a80fbe8b2c0 to your computer and use it in GitHub Desktop.
YQL API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var YQL = require('yql'); | |
var query = new YQL('SELECT * FROM weather.forecast WHERE (location = 94089)'); | |
query.exec(function(err, data) { | |
var location = data.query.results.channel.location; | |
var condition = data.query.results.channel.item.condition; | |
console.log('The current weather in ' + location.city + ', ' + location.region + ' is ' + condition.temp + ' degrees.'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var yqlCallback = function(data) { | |
var wind = data.query.results.channel.wind; | |
alert(wind.chill); | |
}; | |
</script> | |
<script src="https://query.yahooapis.com/v1/public/yql?q=select wind from weather.forecast where woeid in (select woeid from geo.places(1) where text='chicago, il')&format=json&callback=yqlCallback"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Download the following GitHub repository https://github.com/guilhermechapiewski/yql-ios | |
// Copy the yql-ios folder to your project | |
#import "YQL.h"; | |
yql = [[YQL alloc] init]; | |
NSString *queryString = @"select * from yahoo.finance.quote where symbol in (\"YHOO\",\"AAPL\",\"GOOG\",\"MSFT\")"; | |
NSDictionary *results = [yql query:queryString]; | |
NSLog(@"%@",results[@"query"][@"count"]); | |
NSLog(@"%@",results[@"query"][@"results"]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$BASE_URL = "http://query.yahooapis.com/v1/public/yql"; | |
$yql_query = 'select wind from weather.forecast where woeid in (select woeid from geo.places(1) where text="chicago, il")'; | |
$yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json"; | |
// Make call with cURL | |
$session = curl_init($yql_query_url); | |
curl_setopt($session, CURLOPT_RETURNTRANSFER,true); | |
$json = curl_exec($session); | |
// Convert JSON to PHP object | |
$phpObj = json_decode($json); | |
var_dump($phpObj); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2, urllib, json | |
baseurl = "https://query.yahooapis.com/v1/public/yql?" | |
yql_query = "select wind from weather.forecast where woeid=2460286" | |
yql_url = baseurl + urllib.urlencode({'q':yql_query}) + "&format=json" | |
result = urllib2.urlopen(yql_url).read() | |
data = json.loads(result) | |
print data['query']['results'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment