origindesign / noaa
NOAA的预报和当前天气服务API的客户库
0.0.5
2018-09-14 19:02 UTC
Requires
- php: >=5.3.0
- ext-curl: *
README
请注意:新的API仍在开发中。
用于处理NOAA API的PHP库。有关NOAA文档的更多信息,请参阅NOAA文档
可以检索一个点或站点的预报。每小时和每日预报均返回7天的数据。
观测数据为最近5小时
基本用法 - 获取指定点的预报
<?php
include "noaa/autoload.php"; //only needed if not using composer bootstrap
use noaa\util\Cache;
use noaa\Point;
use noaa\NOAA;
$noaa = new NOAA(new Cache);
$point = new Point(43.43, -90.80);
$noaa->setPoint($point);
$hourly = $noaa->getHourlyForecast();
foreach($hourly as $forecast){
echo $forecast->getStart('D, d M H:i:s') . " Temp:" . $forecast->getTemperature() . "\n";
}
基本用法 - 获取指定点的观测数据
<?php
include "noaa/autoload.php"; //only needed if not using composer bootstrap
use noaa\util\Cache;
use noaa\Point;
use noaa\NOAA;
$noaa = new NOAA(new Cache);
$point = new Point(43.43, -90.80);
$noaa->setPoint($point);
//get a station
echo "Observations recorded at: " . $noaa->getStation()->getName()."\n";
$observations = $noaa->getObservations();
foreach($observations as $observation){
echo $observation->getTime('D, d M H:i:s') . " Temp:" . $observation->getTemperature() . "\n";
}