Включает два статичных метода:
YandexWeather::get_region_id($city) - обращается к https://pogoda.yandex.ru/static/cities.xml и возвращает код региона выбранного города $city
YandexWeather::get_weather($region_id) - обращается к https://export.yandex.ru/bar/reginfo.xml?region= и возвращает прогноз погоды в $region_id
Пример:
$city_id = YandexWeather::get_region_id('Санкт-Петербург');
$weather = YandexWeather::get_weather($city_id);
var_dump($weather_id);Вернет:
array(5) {
["now"]=>
array(4) {
["type"]=>
string(8) "ясно"
["wind_speed"]=>
string(1) "2"
["wind_direction"]=>
string(17) "юго-запад"
["temperature"]=>
string(2) "-7"
}
["morning"]=>
array(1) {
["temperature"]=>
string(15) "от -7 до -5"
}
["daytime"]=>
array(1) {
["temperature"]=>
string(2) "-5"
}
["evening"]=>
array(1) {
["temperature"]=>
string(15) "от -4 до -3"
}
["night"]=>
array(1) {
["temperature"]=>
string(2) "-3"
}
}