webit / wwo-local-weather
World Weather Online 本地天气 API 的 PHP 实现
dev-master
2013-09-16 10:08 UTC
Requires
- php: >=5.3.3
- webit/weather-api: dev-master
This package is auto-updated.
Last update: 2024-09-20 22:43:16 UTC
README
这是什么?
来自 http://www.worldweatheronline.com/ 的本地天气 API 实现
使用方法
$apiKey = 'your api key';
$request = new CityRequest($apiKey);
$request->setFormat(CityRequest::FORMAT_JSON); // json is default format
$request->setNumberOfDays(3); // default 2
$request->setCity('New York');
$request->setCountry('USA');
$proxy = new CurlProxy();
$response = $proxy->performRequest($request);
if($response->getSuccess()) {
echo $response->getCurrentWeather() . "\n";
foreach($response->getWeatherList() as $weather) {
echo $weather . "\n";
}
} else {
foreach($response->getErrors() as $error) {
echo $error . "\n";
}
}
待办事项
- XML 响应格式的实现
- CSV 响应格式的实现
- 测试