0

現在、この APIから yr.no の API から現在の時刻のデータを取得しています。特定の日時から温度を取得したいのですが、これを機能させる方法がわかりません。

このデータを取得したい (これは水曜日の予測です):

<time datatype="forecast" from="2012-11-21T15:00:00Z" to="2012-11-21T15:00:00Z">
<location altitude="52" latitude="59.3782" longitude="13.5042">
<temperature id="TTT" unit="celcius" value="7.0"/>
<windDirection id="dd" deg="183.2" name="S"/>
<windSpeed id="ff" mps="3.7" beaufort="3" name="Lett bris"/>
<humidity value="78.3" unit="percent"/>
<pressure id="pr" unit="hPa" value="1020.2"/>
<cloudiness id="NN" percent="100.0"/>
<fog id="FOG" percent="0.0"/>
<lowClouds id="LOW" percent="100.0"/>
<mediumClouds id="MEDIUM" percent="0.0"/>
<highClouds id="HIGH" percent="23.6"/>
</location>
</time>

この予測を取得して自分のサイトで表示するにはどうすればよいですか?

前もって感謝します。

4

1 に答える 1

0

解決しました!作業コードは次のとおりです。

foreach($weather->product->time AS $forecast) {
    $from = $forecast->attributes()->from;
    $to = $forecast->attributes()->to;

    if($from == '2012-11-21T12:00:00Z' AND $to == '2012-11-21T12:00:00Z') {
            echo echo $forecast->location->temperature->attributes()->value.'° C';
        }
}
于 2012-11-19T09:45:53.057 に答える