352.5. サンプル
352.5.1. 例 1 リンクのコピーリンクがクリップボードにコピーされました!
この例では、YQL にクエリーを実行して、シカゴの現在の風と大気のデータを取得します。
from("direct:start")
.to("yql://select wind, atmosphere from weather.forecast where woeid in (select woeid from geo.places(1) where text='chicago, il'");
本文を次のように設定します。
{
"query":{
"count":1,
"created":"2017-11-01T19:37:26Z",
"lang":"en-US",
"results":{
"channel":{
"wind":{
"chill":"32",
"direction":"165",
"speed":"22"
},
"atmosphere":{
"humidity":"71",
"pressure":"994.0",
"rising":"0",
"visibility":"16.1"
}
}
}
}
}
およびヘッダー:
352.5.2. 例 2 リンクのコピーリンクがクリップボードにコピーされました!
この例では、YQL にクエリーを実行して Google の見積もりを取得します。
from("direct:start")
.to("yql://select symbol, Ask, Bid, AverageDailyVolume from yahoo.finance.quotes where symbol in ('GOOG')?env=store://datatables.org/alltableswithkeys&https=false&callback=yqlCallback");
本文を次のように設定します。
/**/yqlCallback({
"query":{
"count":1,
"created":"2017-11-01T19:48:17Z",
"lang":"en-US",
"results":{
"quote":{
"symbol":"GOOG",
"Bid":"1025.57",
"Ask":"1025.92",
"AverageDailyVolume":"1350640"AverageDailyVolume
}
}
}
});
およびヘッダー:
| ヘッダー | 値 |
|---|---|
|
| |
|
| 200 |
352.5.3. 例 3 リンクのコピーリンクがクリップボードにコピーされました!
この例では、YQL にクエリーを実行して、Barack Obama が書いた 1 冊の本を取得します。
from("direct:start")
.to("yql://select * from google.books where q='barack obama' and maxResults=1?format=xml&crossProduct=optimized&env=store://datatables.org/alltableswithkeys");
本文を次のように設定します。
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1" yahoo:created="2017-11-01T20:32:22Z" yahoo:lang="en-US">
<results>
<json>
<kind>books#volumes</kind>
<totalItems>1993</totalItems>
<items>
<kind>books#volume</kind>
<id>HRCHJp-V0QUC</id>
<etag>SeTJeSgFDzo</etag>
<selfLink>https://www.googleapis.com/books/v1/volumes/HRCHJp-V0QUC</selfLink>
<volumeInfo>
<title>Dreams from My Father</title>
<subtitle>A Story of Race and Inheritance</subtitle>
<authors>Barack Obama</authors>
<publisher>Broadway Books</publisher>
<publishedDate>2007-01-09</publishedDate>
...
</volumeInfo>
</items>
</json>
</results>
</query>
<!-- total: 646 -->
およびヘッダー:
| ヘッダー | 値 |
|---|---|
|
| |
|
| 200 |